Regex Tools
Regex Tester & Debugger
Write a regular expression, choose flags, and watch matches highlight in real time with their indexes and capture groups. Everything runs in your browser — nothing is uploaded.
Supported flags: g, i, m, s, u, y, d.
Results
Enter a pattern to start testing. Matches will highlight here live.
How it works
The tester compiles your expression with new RegExp(pattern, flags) and runs it against the test string. Without the global flag it calls String.match(), which returns only the first match; with g it iterates String.matchAll() to collect every match together with its index, capture groups, and named groups. Highlights are rendered by splicing the matched spans back into the text. Under the hood JavaScript regex uses backtracking: when a quantified group like (a+)+ fails, the engine retries every possible split. With nested quantifiers this can explode into exponential time — catastrophic backtracking that can freeze the tab — so keep patterns as linear as possible.
Use cases
Validate emails, URLs, and phone numbers, extract fields from logs, experiment with a pattern before pasting it into code, and debug why an expression matches too much or too little. The live match index and capture-group breakdown make it easy to see exactly what each part of the pattern consumed.
Troubleshooting
- “Invalid regular expression” — unescaped special characters or an unsupported flag combination.
- Page freezes — nested quantifiers such as
(a+)+trigger catastrophic backtracking; rewrite the pattern to avoid nested repetition. - No highlights — add the
gflag; without it only the first match is shown. - Unexpected empty matches — zero-width patterns like
a*match empty spans, which the tester marks with a bar. - Unicode surprises — astral-plane characters such as emoji need the
uflag to be counted as single code points.
FAQ
Which flags are supported?
The tester supports the standard JavaScript flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (Unicode), y (sticky), and d (hasIndices).
Why does my regex freeze the page?
Patterns with nested quantifiers, such as (a+)+, can trigger catastrophic backtracking, where the engine retries exponentially many splits. Rewrite the pattern to avoid nested repetition.
What is the difference between using the g flag and leaving it off?
Without g the tester shows only the first match. With g it iterates every match using matchAll(), listing each one with its index, capture groups, and named groups.
Why do I see empty matches?
Zero-width patterns like a* can match empty spans. The tester marks these with a bar so they are not silently ignored.
Is my text uploaded anywhere?
No. Matching runs entirely in your browser. Your pattern and test string never leave the page.