Regex tester
Runs entirely in your browser. Your files and data never leave your device.
| # | Match | Groups | Named groups |
|---|---|---|---|
| 1 | hello@example.com | ||
| 2 | support@example.co |
About this tool
A regex tester lets you write a pattern and check it against real text right away. Type a pattern, set flags like g, i, or m, and paste in a test string: the tool highlights every match, lists each one with its numbered and named capture groups, and lets you try a replacement string before you commit to it in code.
How does matching and replacement work?
Matching runs on JavaScript’s built-in RegExp engine, so the syntax and flags behave exactly the way they will once the pattern is in your code. Without the g flag, only the first match is found and highlighted, matching how RegExp.exec behaves natively. With g set, the tool collects every match up to a limit of 10,000, which keeps a pattern that matches on nearly every character in a huge input from generating an unusably long list. Zero-length matches, the kind a pattern like a* can produce, are handled by advancing one extra step each time so the scan can’t get stuck in place. Numbered and named capture groups that didn’t participate in a particular match show up as empty strings rather than undefined, so the group list stays easy to read. The replacement field uses native String.prototype.replace substitution syntax, so $1, $<name>, $&, and $$ all work the same way they would in your own code.
What happens if my pattern is slow or invalid?
Matching runs inside a Web Worker rather than on the main thread, so a pathological pattern, one with catastrophic backtracking that can otherwise freeze a tab, doesn’t lock up the page. If a match takes too long, the tool shows a timeout message and restarts the worker automatically, so you can edit the pattern and try again without reloading. An invalid pattern, like unbalanced parentheses or an unknown flag, is caught and reported as an error near the input instead of throwing silently.
Is my test text sent anywhere?
No. Everything, matching, replacing, and highlighting, happens in your browser. Your pattern and test string never leave your machine, so it’s fine to test a regex against a log line with a customer’s email in it, a config file, or any other data you’d rather not paste into a third-party site.
What is this useful for?
Use it to validate input formats like phone numbers or postal codes, pull structured data out of log lines, or check that a replacement pattern with $1 or $<name> produces the output you expect before you drop it into your codebase. See MDN’s guide to regular expressions for the full syntax, or the regex101 community reference if you need explanations for patterns written in other languages.