Regex Explainer
Paste a regular expression to get each token explained in plain English, plus warnings measured in your own browser's engine: greedy versus lazy matching, capture-group count, unicode-flag breakage and anchoring traps.
Every note below is produced by running the pattern against the JavaScript engine in front of you right now, not by looking it up in a table. If your engine disagrees with another one, this page shows the disagreement instead of picking a side.
What the explainer reports, and what it does not check
Every explanation and warning below came from this page's explainer when the site was built, running in Node (V8, the engine Chrome uses). On the page itself, the measured warnings come from your own browser's engine. It checks anchoring with alternation, Unicode property escapes without the u flag, greedy versus lazy quantifiers and the capture-group count. It does not check for catastrophic backtracking; the last example shows why that matters, and the ReDoS guide covers how to spot and fix it.
/^abc|def$/
The most common anchoring mistake: ^ and $ each guard only one branch.
9 tokens, 0 capture groups
^Start of input (or of a line, with the m flag).|OR. Its reach is the whole surrounding pattern, not just the word beside it — ^a|b matches any b anywhere.$End of input (or of a line, with the m flag).
Warnings
- ^ with alternation. ^ binds to one alternative, not the whole list. /^a|b/ against "zb" matched "b" — the ^ only guarded the first branch. Wrap it: ^(a|b).
/\p{L}+/
Compiles without the u flag and silently means something else.
5 tokens, 0 capture groups
\pUnicode property escape. Only treated as a property when the u or v flag is set.{A brace with no matching quantifier inside it is just a character.+Repeat one or more times. Greedy: takes as much as it can, then gives characters back only if the rest of the pattern needs them.
Warnings
- \p{...} without the u or v flag. It compiled, which is the trap: without u or v this is an identity escape, so it searches for the letter p and the braces around it rather than a Unicode property. Measured here — matches "é": NO; matches its own literal spelling "p{L}+": yes. Add the u flag to mean a property.
/\p{L}+/u
With the u flag the same pattern is a Unicode letter class, and the warning clears.
5 tokens, 0 capture groups
\pUnicode property escape. Only treated as a property when the u or v flag is set.{A brace with no matching quantifier inside it is just a character.+Repeat one or more times. Greedy: takes as much as it can, then gives characters back only if the rest of the pattern needs them.
Warnings: none
/(\d+)-(\d+)/
No warnings; the explanation counts two capture groups.
3 tokens, 2 capture groups
(\d+)Capturing group — its match is returned as a numbered result.(\d+)Capturing group — its match is returned as a numbered result.
Warnings: none
/(a+)+$/
No warning, and this is the case to know about: a quantifier nested inside another can backtrack catastrophically on input like "aaaaaaaaaaaaaaaaaaaaaaaa!". The explainer does not check for it.
3 tokens, 1 capture group
(a+)Capturing group — its match is returned as a numbered result.+Repeat one or more times. Greedy: takes as much as it can, then gives characters back only if the rest of the pattern needs them.$End of input (or of a line, with the m flag).
Warnings: none