Regex Explainer

Paste any regular expression and get a plain-English breakdown of every token — anchors, character classes, groups, quantifiers, lookarounds, the lot. Useful when you've inherited a cryptic pattern from a stranger's codebase, or when you've written one yourself and want to verify it does exactly what you think. Everything runs in your browser; nothing is uploaded.

Try an example:

How to Use This Tool

  1. Paste your regex into the input. Both /pattern/flags and a bare pattern work — the parser auto-detects which form you used.
  2. Read the indented breakdown. Each line is one token in plain English; indentation shows how quantifiers and groups nest.
  3. Try an example by clicking one of the example buttons. Watch how a real-world pattern decomposes piece by piece.
  4. Verify the pattern is valid — if not, the status bar shows the exact RegExp error, including the position of the problem.
  5. Confirm with the tester. Open the regex tester in another tab to check the pattern matches the strings you expect, then come back here to double-check what each token does.

Why a Regex Explainer Is Useful

Regular expressions are dense — a single line can encode behaviour that takes a paragraph of prose to describe. That density is the point: regex is fast to write once you know the syntax, and concise to share once you know what you're looking at. The cost is that an unfamiliar pattern is unreadable until you've parsed it character by character in your head, and even experienced developers misread their own regex months after writing it. An explainer turns the parsing back into something a human can skim.

The most common reasons to reach for an explainer: inheriting code from someone who didn't comment their patterns, debugging a regex that nearly works, learning a new feature like lookbehind or named groups, or auditing a regex that handles security-relevant input. In all four cases the same problem applies — you have to be confident you understand every piece, not just the overall shape. A token-by-token breakdown forces you to engage with the parts you would otherwise skim past.

This tool only describes the structure; it does not run the pattern against test data. For that, the regex tester is the right companion — paste the same pattern, paste sample text, and watch matches highlight in real time. Pair the two: the explainer tells you what the pattern says, the tester tells you what it does.

Reading the Output

The breakdown is a flat indented list, mirroring the structural depth of your pattern:

If a token has unfamiliar terminology, jump to the regex cheat sheet for a definition. The cheat sheet's structure mirrors the categories the explainer uses, so you can map terms to syntax quickly.

Frequently Asked Questions

How does the regex explainer work?
The explainer parses your regex into a tree of tokens — anchors, character classes, groups, quantifiers, alternations, escapes, and backreferences — then walks the tree producing a plain-English description of each piece. Indentation shows nesting, so you can read the structure at a glance. The pattern is also validated by passing it to the browser's RegExp constructor, so syntax errors are caught with the same error message JavaScript would produce at runtime.
What regex syntax does the explainer support?
All common syntax: anchors (^, $, \b, \B), character classes (\d, \w, \s and their negated forms, plus [abc], [a-z], [^abc]), quantifiers (*, +, ?, {n}, {n,}, {n,m} and their lazy variants), groups (capturing, non-capturing, named with both JavaScript and Python syntax, lookaheads, lookbehinds), alternation (|), backreferences (\1, \k<name>), Unicode escapes (\uXXXX, \xXX), and Unicode properties (\p{...}). Most patterns from JavaScript, Python, Go, Java, and PCRE engines parse cleanly.
Should I include the slashes around my regex?
Both forms work. If you paste /pattern/flags the explainer strips the slashes and parses the flags separately, showing what each flag does. If you paste just the pattern without slashes, the explainer treats the entire input as the pattern body and assumes no flags. Use whichever form matches the source you copied from — common tools like JavaScript code, regex101, and many docs use the slashed form.
Why is my regex marked as invalid?
The explainer uses the browser's built-in RegExp parser to validate, so any error you see is the actual JavaScript regex error. Common causes: unbalanced parentheses or brackets, an invalid escape sequence, an empty alternative, a quantifier with no preceding atom, or a Python-only feature (like (?P<name>) without the new u flag) being parsed in JavaScript-only mode. The status line shows the underlying error, which usually points to the position of the problem.
Can I share the explanation?
All processing happens in your browser, so there is no shareable URL by default. To share an explanation, copy the regex and paste this page's URL — anyone visiting will get the same explanation when they paste the same pattern. Nothing is uploaded, logged, or saved server-side, which means you can paste production patterns containing internal naming conventions without exposing them outside your machine.