Regex tester
DevNo. 55 / 84
Test a regular expression against your own text and see every match, its position, the capture groups and a live replacement preview.
a regex is a cat — elegant, powerful, and it will knock something off the table.
work surface
Math, not advice — results are indicative.Read the disclaimer.
most-used utilities
Find email addresses
Run one pattern over a pasted contact list and count how many entries actually look like addresses.
Log line IDs
Pull request IDs out of a wall of server output without scrolling and squinting at hex.
Safe find and replace
Preview a substitution on a sample paragraph before letting it loose on the whole file.
pro tips
Test with the ugliest real input you have. A pattern that passes on hello at example dot com often collapses on name plus tag at a subdomain with two dots.
A dot matches almost anything, so a literal dot needs a backslash. Half of all broken patterns are a missing backslash in front of a dot.
If a pattern works alone but fails inside a larger one, check the anchors. A stray ^ or $ is cheap to add and ruthless in effect, especially with the multiline flag on.
what it does
Type a pattern, pick your flags and paste the text you want to test. The widget compiles the expression with the browser's own engine and updates on every keystroke: whether it matches, every match with its start index, the capture groups it found, and a replacement preview you can copy.
It is the tool for the moment a pattern from a forum answer meets real data. Checking an email rule against a messy export, pulling IDs out of log lines, confirming that a route matcher does not eat a trailing slash, or watching a find-and-replace do its thing before you run it on 400 files.
Say the pattern is (\w+)@(\w+[.]\w+) with the global flag and the text holds two addresses. You get two matches, four numbered groups, and a preview showing how $1 at $2 rewrites each address. The indices tell you exactly where each match starts, which is what you need when the pattern goes back into your code.
The flags behave as they do everywhere else: g finds every match, i ignores case, m makes anchors respect line breaks, s lets the dot cross them, and u turns on Unicode mode. The g flag also decides whether the replacement touches every match or only the first. Everything runs locally, with no server, no request and no history of what you tried.
quick answers
Which regex flavor is this?
The one built into your browser, which in practice means JavaScript. Modern features such as named groups, lookbehind and Unicode property escapes work in current browsers; very old ones may not. Nothing is translated or emulated.
Why does the replacement only change the first match?
Because the g flag is off. Without it, replace stops at the first hit, exactly as it does in code. Turn g on and the replacement applies to every match in the text.
Can a pattern freeze the page?
Yes. Patterns with nested quantifiers, such as (a+)+ followed by a character that never appears, can take exponential time on a long string. The expression runs on the page's main thread, so the tab stops responding. Close the tab and simplify the pattern.