Regex tester
Type a pattern, paste your text and see all matches instantly. Choose With position and groups to see where every match is and what each group captures, or Replace to search and replace with references such as $1. The tester uses JavaScript regular expressions.
How it works
-
Paste your code
Paste the code in the left box or open a file. No code to hand? Click Example.
-
Instant result
The result appears as you type. If there is an error, you see the line and character.
-
Copy or download
Copy the result with one click or save it as a file for your editor or project.
Common building blocks
| Pattern | Meaning |
|---|---|
| \d | a digit, \d+ one or more digits |
| \w | a letter, digit or _ |
| \s | a space, tab or line break |
| . | any character except a line break |
| [a-z] | one character from the range |
| ^ and $ | start and end (of the line with the m flag) |
| \b | a word boundary |
| ( … ) | a group, available as $1, $2 … |
| (?<name> … ) | a named group: $<name> |
| ?, *, +, {2,4} | 0 or 1, 0 or more, 1 or more, 2 to 4 times |
Search and replace
In Replace with, $1 refers to the first group, $& to the whole match and $<name> to a named group. The example turns dates like 12-09-2026 into 2026-09-12 with the pattern (\d{2})-(\d{2})-(\d{4}) and the replacement $3-$2-$1. Use \n for a new line.
Flags
The g flag (all matches) is always on. You can also type /pattern/i, as in code; the flags after the slash are used. A pattern that works in JavaScript usually works in Python, PHP and Java too, but not always in exactly the same way.
Frequently asked questions
Is the regex tester free?
Yes. The regex tester is completely free, with no account, sign-up or usage limit.
Is my code stored?
No. Your code is processed in your browser and is not sent to a server or stored.
Does it work on my phone?
Yes. The tool works in any modern browser on a phone, tablet or computer.