Regex Explainer
Breaks any regular expression down into its parts, anchors, groups, character classes, quantifiers, with a plain-English explanation of each.
This guide is not yet available in your language and is shown in English.
Tool guide
What this tool does
Regex Explainer parses any regular expression and breaks it into its constituent pieces, anchors, character classes, groups (capturing, non-capturing, named, lookaheads/lookbehinds), quantifiers and escape sequences, explaining each one in plain English in matching order, with nested groups indented to show their scope.
Reading someone else’s regular expression, or your own from six months ago, can feel like deciphering a dense code even when every individual symbol is technically familiar; a long pattern with nested groups and lookaheads is genuinely hard to parse mentally all at once.
This explainer walks through a pattern piece by piece in the order it would actually match, breaking out anchors, character classes, capturing and non-capturing groups, named groups, lookaheads and lookbehinds, quantifiers and escape sequences, explaining each one in plain English, with nested groups visually indented to show exactly what’s inside what.
How to use Regex Explainer
- Paste your regular expression Pattern.
- Enter any Flags the pattern uses, to see their meaning explained too.
- Read through the breakdown, in matching order, from top to bottom.
- Toggle Compact view to collapse the nesting indentation if you prefer a flat list.
Tips for better results
- Nested groups are indented to show their scope at a glance, a lookahead or capturing group containing other tokens will show those tokens indented one level deeper.
- A quantifier (like + or {2,4}) always explains itself as applying to "the previous token", which is the atom, character class or group that came immediately before it.
- Named capture groups ((?<name>...)) and named backreferences (\k<name>) are explained with their actual name, making it easier to trace which part of a long pattern they refer to.
- Pair this with the Regex Tester: understand what a pattern is supposed to do here, then confirm it actually does that against real sample text there.
Common use cases
- Understanding an unfamiliar or complex regular expression found in someone else’s code.
- Documenting what a regex validation rule in your own codebase actually does, for a comment or README.
- Learning regex syntax by pasting in example patterns and reading the piece-by-piece explanation.
- Spotting a likely mistake in a pattern by seeing its literal, piece-by-piece interpretation rather than your intended one.
Common mistakes to avoid
- Assuming the breakdown reflects your intent rather than the pattern’s literal behaviour; this tool explains exactly what the regex engine will do, which is often the fastest way to spot where intent and implementation diverge.
- Overlooking that lookaheads and lookbehinds don’t consume characters; they check a condition without including it in the match itself, which this explainer calls out but is easy to forget when reading quickly.
- Expecting a fully invalid pattern to still produce a breakdown; a genuinely malformed regex is flagged with the underlying JavaScript error instead.
Frequently asked questions
Does this explain any regex flavour, or just JavaScript?
The pattern is validated and parsed as JavaScript RegExp syntax; most core constructs (groups, classes, quantifiers, lookarounds) are shared across common regex flavours, but flavour-specific features outside JavaScript’s syntax won’t be recognised correctly.
What does the indentation in the breakdown mean?
It shows nesting: a token indented further in is inside the group, lookahead or lookbehind listed just above it at a shallower indent level.
Can I use this to write a new regex, not just explain an existing one?
It’s most useful for understanding a pattern you already have; for building one from scratch, the Regex Pattern Library and Regex Tester are better starting points.
Why does a quantifier show as its own line?
Quantifiers (*, +, ?, {n,m}) always modify the token immediately before them, so they’re shown as a separate explained step saying exactly what they repeat and how.
Related articles
Feedback & suggestions
Help us improve Regex Explainer. We read every message.