Regex Tester
Test regular expressions with live highlighting, capture groups and replace. Runs safely in a worker, so a runaway pattern cannot freeze the page.
Matches highlighted
Matches
Related tools
All Developer tools →This tool runs entirely in your browser. Nothing you enter is sent to our servers, so there is nothing for us to store or see.
About the Regex Tester
Write a regular expression and watch it match against your text as you type. Matches are highlighted in place, every capture group — numbered or named — is listed with its value, and a replace field shows the result of applying the pattern.
One design decision is worth explaining, because it is the reason this tool will not lose your work. Regular expressions cannot be interrupted once they start. A pattern like (a+)+b against a string of forty as makes the engine explore an exponential number of paths, and on the main thread that means a frozen tab, an unresponsive page and whatever you had typed gone. Here the matching runs in a Web Worker with a two-second deadline; if it overruns, the worker is terminated and you get an explanation of what went wrong instead of a dead page.
That failure mode has a name — catastrophic backtracking — and it is worth recognising, because the same pattern that hangs this page will take down a server if it reaches production. When a timeout happens the tool points at the likely cause, usually a quantifier nested inside another one.
The syntax is JavaScript's, which is close to but not identical to PCRE. Lookbehind is supported in every current browser; possessive quantifiers and atomic groups are not, and recursion is not available at all.
How to use the Regex Tester
-
Write your pattern
Type it between the slashes — no need to add them yourself. Toggle the flags underneath; g for every match, i to ignore case, m to make ^ and $ work per line.
-
Paste your test string
Matches highlight live in the pane below it, with adjacent matches shaded differently so you can see where one ends and the next begins.
-
Inspect the matches
Each match is listed with its position and every capture group. Named groups show their names; unnamed ones are numbered as the engine sees them.
-
Try a replacement
Enter replacement text using $1 for a numbered group or $<name> for a named one, and the full result appears underneath ready to copy.
Frequently asked questions
What is catastrophic backtracking?
When a pattern can match the same text in many different ways — usually because one quantifier is nested inside another, like (a+)+ — the engine tries every combination before giving up. The number of combinations grows exponentially with input length, so a forty-character string can take longer than the age of the universe. Rewriting the pattern to remove the ambiguity fixes it.
Why does the tool stop after two seconds?
Because a running regular expression cannot be interrupted by anything except killing the thread it is on. Matching runs in a Web Worker precisely so there is a thread to kill; without that, a runaway pattern would freeze the page and lose whatever you had typed. Two seconds is far longer than any reasonable pattern needs.
Which regex flavour is this?
JavaScript, since it runs in your browser. It is close to PCRE for everyday use — character classes, quantifiers, groups, lookahead and lookbehind all behave the same. It lacks possessive quantifiers, atomic groups, recursion and \A and \z anchors, so a pattern copied from PHP or Python may need small adjustments.
Is my test data sent anywhere?
No. The pattern and the text are matched entirely in your browser, and neither is transmitted or stored. That matters here more than in most tools, since regex testing usually means pasting a sample of real production data.
How do I match a literal dot, dollar sign or bracket?
Escape it with a backslash: \. \$ \[ and so on. The "Escape the first line as a literal" button does this for you — it takes the first line of your test string and turns it into a pattern that matches exactly that text, which is a useful starting point before generalising.
Why does my pattern only find the first match?
The global flag is off. Without g, a regular expression stops at the first match by design. Tick the g checkbox to find them all. This tool shows the real behaviour rather than quietly adding the flag, because that difference matters when you take the pattern back to your code.