Regex Explainer
Paste any regular expression and get a plain-English breakdown of every token — anchors, quantifiers, groups, and more.
- Pattern is anchored — it must match the entire string (or line with m flag).
All analysis runs locally in your browser — your patterns stay private.
Regular expressions are compact, and a pattern such as ^(25[0-5]|2[0-4]\d|[01]?\d\d?) is hard to read at a glance. This tool splits a JavaScript regex into its tokens (anchors, character classes, quantifiers, groups, escapes, backreferences and alternation) and describes each one in plain English, colour-coded by category.
Above the token breakdown, a short summary tells you whether the pattern is anchored, how many numbered and named capture groups it has, whether it uses lookarounds, lazy quantifiers or alternation, and which flags are active. The m and s flags change the explanation itself: with m, ^ and $ are described as line anchors, and with s the dot is described as matching newlines.
The explainer reads the pattern; it does not run it. To see what a pattern actually matches in real text, with highlighting and capture group values, use the Regex Tester. The two work well together: understand the pattern here, then confirm its behaviour there.
- Type or paste a pattern into the field without the surrounding slashes, or click one of the examples (Email, URL, IPv4, Date, Hex colour).
- Toggle the flags your code uses (g, i, m, s, u) so the explanation matches how the pattern will run.
- Read the plain-English summary for an overview of the pattern's structure.
- Click any coloured token, or any row in the All Tokens list, to open a detailed description of that token.
- Click Copy All to copy the summary and token breakdown as plain text, for a code review comment or documentation.
- Token-by-token breakdown with a short description and a longer detail for each token
- Colour coding by category: anchor, quantifier, group, character class, literal, alternation, escape, backreference
- Summary of anchoring, capture groups, lookarounds, lazy quantifiers, alternation and flags
- Flag-aware wording for ^, $ and . when m or s is enabled
- Pattern validated by the browser's regex engine first, with the engine's error shown if it is invalid
- Five example patterns to load with one click, and Copy All for a plain-text explanation
A fixed-format phone number
Pattern: ^\d{3}-\d{4}$
^ Start of string
\d Any digit [0–9]
{3} Exactly 3 times
- Literal "-"
\d Any digit [0–9]
{4} Exactly 4 times
$ End of stringThe summary adds that the pattern is anchored at both ends, so it must match the entire string (or each line with m).
Named capture groups
Pattern: (?<year>\d{4})-(?<month>\d{2})
(?<year> Named capture group "year"
\d Any digit [0–9]
{4} Exactly 4 times
) End of group
- Literal "-"
(?<month> Named capture group "month"
...The detail view for each named group tells you how to read it in code, e.g. match.groups.year.
A lazy quantifier
Pattern: <.+?> < Literal "<" . Any character except newline +? 1 or more (lazy) > Literal ">"
The summary notes one lazy quantifier. Turn on s and the dot is re-described as matching newlines too.
Invalid regular expression: /(\d+/: Unterminated group
The pattern does not compile in JavaScript, so no breakdown is produced. Here the group is never closed.
Fix the syntax the message points to, or escape the character (\( or \[) if you meant it literally.
The slashes and flags appear as literal tokens
The pattern was pasted with its delimiters, such as /abc/i. The field expects only the part between the slashes.
Remove the slashes and set the flags with the toggles below the field.
\\d is explained as a literal backslash followed by the letter d
The pattern was copied from a string literal like "\\d+", where backslashes are doubled.
Remove one backslash from each pair so the token reads \d.
Does the explainer test the pattern against text?
No. It only analyses the pattern itself. Paste the same pattern into the Regex Tester to see matches, positions and capture group values against sample input.
Which regex syntax does it understand?
JavaScript regex syntax: anchors, \b and \B, character classes and ranges, \d \w \s and their negations, all quantifiers including lazy forms, capturing, non-capturing and named groups, lookahead and lookbehind, numbered backreferences such as \1, and \n \t \r \0 \xHH \uHHHH escapes.
Are there patterns it explains only partially?
Yes. Named backreferences (\k<name>) and Unicode property escapes (\p{L}) get a generic "escaped character" description. The breakdown is a flat list of tokens, so nesting is shown by opening and closing group tokens rather than a tree, and a character class is explained as one token listing its contents.
Why do I get an error instead of an explanation?
Every pattern is first compiled by your browser's JavaScript engine. If it is invalid there, for example an unclosed ( or [, the engine's error message is shown, because explaining a pattern that cannot run would be misleading.
Is my pattern sent to a server or an AI service?
No. The explanation comes from a parser that runs in your browser, so the output is the same every time for the same pattern and flags.
- Regex TesterTest and debug regular expressions with live match highlighting and group capture.
- Text CompareCompare two text inputs line-by-line with diff highlighting, case and whitespace toggles.
- Diff CheckerCompare two text inputs and visualize differences with color-coded highlighting.
- Lorem Ipsum GeneratorGenerate placeholder text — paragraphs, sentences, or words for design mockups and prototypes.