Regex tester
See matches in real time
Test string
Matches
Replace preview
What you enter is never sent to a server. Everything is processed in your browser on this device.
How to use
- Type your regex in Pattern, without the surrounding slashes.
- Turn on the Flags you need. Only global (g) is on at first.
- Enter text in Test string. Matches are highlighted, and Capture groups lists each match’s index and group values.
- To preview a replacement, type something like $1 in Replace preview.
FAQ
Which regex flavor does it use?
JavaScript (RegExp), as built into your browser. Named groups (?<name>…) and lookbehind work, but PCRE and Java features like possessive quantifiers (a++) or the \A and \Z anchors don’t. If the pattern is for another language, double-check it there.
Why is only one match found?
Without the global (g) flag, only the first match is found. Turn on g to find them all. The replace preview also changes only the first match when g is off.
What’s the difference between the m and s flags?
With multiline (m), ^ and $ match at the start and end of each line instead of the whole text. With dot matches newline (s), . also matches line breaks, so one pattern can span several lines.
It stopped because it didn’t finish within 1 second.
Patterns like (a+)+ can try a huge number of ways to split the same text, a problem known as catastrophic backtracking. The regex runs in a background thread (Web Worker) and is stopped after 1 second, so the page itself doesn’t freeze. Rewrite the pattern to avoid nested repetition.
What can I use in the replacement?
$1, $2 for numbered groups, $<name> for named groups, $& for the whole match, and $$ for a literal dollar sign. If you leave the replacement empty, the preview shows the text with the matches removed, along with a note saying so.
What if there are a lot of matches?
Up to the first 1000 matches are found and highlighted, and the Capture groups table shows the first 100 of those. A notice appears whenever results are cut off.
