How to use Regex Explainer
- Paste the regular expression (a literal such as /…/gi also works).
- Enter the flags you use so anchors and the dot are described correctly.
- Read the summary and the table; expand the parse tree for the full structure.
Regex Explainer features
- Token-by-token table with type and a plain-English sentence for each element
- Nested view of groups, classes and quantified elements
- Understands named groups, lookahead/lookbehind, lazy quantifiers, back-references and Unicode properties
- Flag-aware wording for ^, $ and the dot
- JSON parse tree for documentation or tooling
- Precise error position when the pattern is invalid
Regex Explainer example
Explain an ISO date pattern
Input:
^(?<year>\d{4})-(?<month>0[1-9]|1[0-2])$Output:
^ → Asserts position at the start of the string.
(?<year>\d{4}) → Named capturing group "year" (#1)…
\d{4} → Matches a digit (0–9), exactly 4 times (greedy).
- → Matches a hyphen "-" literally.
(?<month>0[1-9]|1[0-2]) → Named capturing group "month" (#2)…
$ → Asserts position at the end of the string.Frequently asked questions about Regex Explainer
What does the explainer understand?
Literals, escapes (\d \w \s \b, \xhh, \uhhhh, \p{…}), character classes and ranges, all group types (capturing, named, non-capturing, lookahead, lookbehind), greedy and lazy quantifiers, alternation, anchors and numbered or named back-references.
Why does the explanation mention multiline or dotAll?
Flags change the meaning of ^, $ and the dot. Enter the flags you use so the wording matches the actual behaviour.
Can it explain PCRE or Python-specific syntax?
Most syntax is shared, but engine-specific constructs such as possessive quantifiers (a++), atomic groups (?>…) or inline flags (?i) are not part of JavaScript and are reported as errors.
How are groups numbered?
By the position of their opening parenthesis from left to right. Non-capturing groups and lookarounds do not get a number.
Technical notes
A hand-written recursive-descent parser builds an AST (alternation → sequence → quantified atoms) mirroring ECMAScript grammar. Each node carries its raw source, offsets and a description; the same parser powers the catastrophic-backtracking guard in the Regex Tester.