Regex Tester
Test patterns with live matches and groups — and a guard against the one that hangs.
What you provide
How this reads your output
Enter a pattern without the surrounding slashes, pick the flags, and type or paste text to test against. Matching runs on every keystroke and lists each match with its position, its numbered groups and any named groups. The regular expression is constructed fresh for every run — a retained global pattern carries its lastIndex between calls and returns different results for identical input, which is one of the most confusing bugs in this area and one that testers reproduce faithfully. Before any of that, the pattern is checked for a quantifier applied to a group that is itself quantified. That shape can take exponential time on input that nearly matches, and in a browser it is the main thread that stops — so the run is withheld and the shape explained instead.
What the results mean
- Capture groups
- The bracketed sections, numbered from 1. Named groups appear by name where the pattern uses them.
- Global flag
- Without it, code that uses this pattern returns only the first match. The list here shows what a global run would find, so the distinction is worth keeping straight.
- Multiline
- Makes ^ and $ match at each line break rather than only at the start and end of the whole input. The usual fix when a line-anchored pattern matches nothing.
- Nested quantifier
- A quantified group whose contents are also quantified, like (a+)+. The shape behind catastrophic backtracking, and the reason a pattern can take a service down.
Common problems and fixes
- My pattern matches nothing
- Check the anchors first. ^ and $ with multiline off require the pattern to match the entire input, not a line of it.
- It matches too much
- Quantifiers are greedy by default: .* takes everything to the last possible match. Add a question mark to make them lazy, or use a negated character class instead of a dot.
- The pattern is refused as risky
- It contains a quantifier applied to an already-quantified group. Rewrite the inner group so the two cannot overlap — anchoring the pattern often removes the ambiguity entirely.
- It works here but not in my language
- Lookbehind, named group syntax and Unicode property escapes all vary between engines. Check the target language's documentation for the specific construct.
Frequently asked questions
What is catastrophic backtracking?
When a pattern gives the engine many equivalent ways to match the same text — typically a quantifier on a group that is itself quantified, like (a+)+ — the engine tries all of them before concluding that the input does not match. The number of attempts grows exponentially with the input length, so a string of thirty characters can take minutes. It has taken down real services, and in a browser it freezes the tab rather than timing out, which is why this tool refuses to run that shape.
Why does my global regex return different results each time?
A regular expression with the global flag keeps a lastIndex property between calls, and test() and exec() both advance it. Reusing the same object therefore alternates between finding a match and finding nothing. Construct it fresh each time, or use matchAll, which handles it for you.
Are my pattern and test data sent anywhere?
No. Everything runs in your browser. Test data in this category is frequently real log lines or customer records, which is exactly why that matters.
Put this on your own site
Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.
<iframe src="https://runthetests.com/embed/regex-tester/" width="100%" height="720" style="border:1px solid #e5e5e5;border-radius:8px" title="Regex Tester" loading="lazy"></iframe>
Preview it at https://runthetests.com/embed/regex-tester/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.