Back to Developer
Regex explainer — AST tree with per-token English notes

Regex explainer — AST tree with per-token English notes

Break down a JavaScript regular expression into its AST and explain each piece — character classes, quantifiers, groups, lookarounds, flags — in plain English. Comes with sample patterns for email, URL, and date so you can grok common regexes at a glance. Parsed with regexp-tree; syntax errors are shown verbatim. Runs entirely in your browser.

developertextconversion

How to use

Enter a regex pattern and flags (g / i / m / s / u / y / d), then press Explain to see a tree-style breakdown of each piece. The Sample button loads common patterns — email, URL, date — with one click. Character classes, quantifiers, groups, lookarounds, back-references, and anchors are all supported. If the pattern fails to parse, the error is shown verbatim so you can pinpoint the cause. Parsing happens locally via regexp-tree — nothing is uploaded.

FAQ

Is text uploaded?
No. Both the parse (via regexp-tree) and the explanation render entirely in your browser. Your pattern never leaves your device.
How does this differ from regex-test?
regex-test answers "does it match?" and "where does it match?" against sample text. regex-explain answers "what does the pattern mean?" — it walks the syntax tree and labels every piece. Use this tool when reading an unfamiliar regex or debugging someone else's pattern.
Does this support flavors other than JavaScript?
No. The parser assumes ECMAScript (JavaScript) regex syntax. Constructs unique to Python / Perl / PHP / .NET / Java (e.g. `(?P<name>...)`, `\A`, `(?#comment)`) will fail to parse.
Which constructs are explained?
Literal characters, meta characters (`\d \w \s .` etc.), character classes `[a-z]` and negated classes `[^...]`, quantifiers (`+ * ? {n,m}`, greedy and lazy), groups (`(...)`, `(?:...)`, `(?<name>...)`), anchors (`^ $ \b \B`), lookarounds (`(?=...)` `(?!...)` `(?<=...)` `(?<!...)`), back-references (`\1` `\k<name>`), and every standard flag.
Are the sample patterns production-ready?
They're learning aids. Email / URL / phone / ISO date / hashtag patterns are decent first cuts but should be unit-tested for edge cases (a `.museum` TLD, IPv6 URLs, Japanese era dates, etc.) before shipping.

Related tools