What is a regex explainer?
A regex explainer reads a regular expression and describes what each part does, in plain English. Paste in a pattern such as ^\d{3}-\d{4}$ and you get a line for every token: ^ means the start of the string, \d means any digit, {3} means exactly three times, and so on. The default pattern has 7 tokens and is 13 characters long.
Regular expressions are powerful and unreadable. A pattern copied from a forum or inherited in a codebase can look like random punctuation, and the only way to trust it is to understand it. An explainer turns the punctuation into sentences, which is the fastest way to learn what a pattern actually matches.
This tool is a learning aid and a debugging aid. Use it to decode a pattern you found, to check a pattern you wrote, or to learn regex one token at a time. It covers the common syntax — anchors, classes, quantifiers, groups, and alternation — and reports an invalid pattern instead of guessing.
How the explainer works
The explainer walks the pattern from left to right, one token at a time. A token is the smallest meaningful piece: a single character such as ^, a two-character escape such as \d, a character class such as [a-z], or a quantifier such as {3}. The default pattern breaks into 7 tokens: ^, \d, {3}, -, \d, {4}, and $.
Each token gets one line in the output, with the token itself followed by its meaning. The ^ line says "Start of the string", the \d line says "Any digit (0-9)", and the {3} line says "Exactly 3 times". Reading the lines in order reads the pattern as a sentence: start of the string, three digits, a dash, four digits, end of the string.
The pattern is also checked for validity as it is explained. A pattern with an unclosed bracket or an invalid escape is reported as invalid, with the error message from the JavaScript engine. An invalid pattern has no explanation, because a broken pattern has no reliable meaning.
Anchors and character classes, explained
Anchors mark positions, not characters. ^ matches the start of the string and $ matches the end, so ^\d{3} means three digits at the very start, not three digits anywhere. A pattern without anchors matches anywhere in the text, which is the most common source of surprise for beginners.
Character classes match sets. \d matches any digit from 0 to 9, \w matches any word character — a letter, a digit, or an underscore — and \s matches any whitespace. The capital versions mean the opposite: \D matches any character except a digit, \W any character except a word character, and \S any character except whitespace.
A bracket class lists its members: [abc] matches a, b, or c, and [a-z] matches any lower-case letter. A ^ inside the brackets negates the class, so [^0-9] matches any character except a digit. Brackets are the way to spell a set that has no shorthand.
Anchors are the tokens that say where a match must sit, rather than what it must contain. A caret at the start says the match must begin at the start of the text, and a dollar sign at the end says it must end at the end, so a pattern with both anchors must match the whole text rather than a part of it. Without anchors, the same pattern can match a substring anywhere, which is why a pattern that validates a whole field needs both. The explainer names each anchor in plain words, so a pattern that looks like it should match the whole string but does not is easy to diagnose.
A worked example: a phone code pattern
Take the default pattern, ^\d{3}-\d{4}$, which is 13 characters. It has 7 tokens. The explainer reads it as: start of the string, then a digit exactly three times, then a literal dash, then a digit exactly four times, then the end of the string. Together, that means "three digits, a dash, four digits, and nothing else" — the shape of a code such as 555-1234.
Change one token and the meaning changes. Replace {3} with {2,4} and the first part becomes "between 2 and 4 digits", so 55-1234 and 5555-1234 both match. Replace \d with \w and the pattern accepts letters too, so ABC-DEFG matches. The explainer shows each change in plain English, which is how you check that the pattern means what you intended.
Try a group to see the next idea: ^(\d{3})-(\d{4})$ adds two capturing groups, and the explainer reports them as groups that save their matches as $1 and $2. A regex tester shows what the pattern matches; this tool shows what it means.
Who uses a regex explainer, and why
Learners are the main users. Regular expressions are usually learned by copying patterns, and an explainer turns each copied pattern into a lesson. Reading the explanation of a pattern you found is faster than reading a tutorial chapter, because the pattern is one you actually need.
Developers inheriting code are the second group. A codebase with a pattern such as ^[A-Z]{2}[0-9]{4}$ needs someone to understand it before changing it, and the explainer says in one line per token what the pattern does. That understanding is what stops a well-meaning edit from breaking a validation rule.
Reviewers and testers are a third group. A pattern in a code review or a test case needs checking, and the explainer gives the reviewer the meaning without making them decode the punctuation. A case converter normalises the text first, so a pattern written for lower-case letters matches text that arrived in mixed case.
Code reviewers are a third group. A pull request that adds a pattern to validate input needs a reviewer who can read the pattern, and a reviewer who cannot read regex will either approve it blindly or ask the author to explain it. The explainer is the third option: paste the pattern and the explanation is the review. A pattern whose explanation does not match the comment above it is a bug, and the explainer makes that mismatch visible in seconds.
Regex explainer vs tester and sample generator
An explainer describes a pattern; a tester shows its matches; a sample generator produces strings that match it. The regex tester on this site highlights every match of a pattern in your text, which answers "what does this match here?" This tool answers "what does this mean?" — a different question, and often the more useful one.
A word counter measures the text the pattern runs on, which matters when a pattern must match a whole field rather than part of one. The explainer, the tester, and the counter together cover understanding, testing, and measuring — the three checks before a pattern goes into production.
Use them in order: explain the pattern to understand it, test it on real text to check it, and count the text to see its shape. A pattern that passes all three checks is one you can trust in production.
An explainer is not a tester, and the distinction matters when the question is whether a pattern matches a particular string. An explainer describes what the pattern means, which answers whether the pattern is written correctly. A tester runs the pattern against a string, which answers whether the string matches. Use the explainer to check the meaning and the tester to check the match — a pattern can be correctly written and still not match the string you expected, and the two tools together show which side is wrong.
Common regex mistakes the explainer reveals
The first mistake is an unanchored pattern. A pattern of \d{3} without ^ and $ matches three digits anywhere, including inside a longer number — 12345 contains a match. The explainer shows whether the anchors are there, which is the first thing to check.
Second: a dot that means any character. A pattern of example.com matches exampleXcom, because the dot is a wildcard. The explainer lists the dot as "any single character", which is the hint to escape it as \. when you mean a literal dot.
Third: greedy quantifiers. A pattern of .* matches as much as it can, which surprises beginners who expect it to match as little as possible. The explainer describes * as "0 or more times (greedy)", which is the reminder that greedy is the default.
Fourth: a character class that is not what it seems. [a-z] matches lower-case letters only, so a pattern of ^[a-z]+$ rejects "Hello" with a capital H. The explainer lists the class as "any one character from a-z", which makes the gap obvious.
A second mistake is reading a character class as a sequence. A class such as [abc] means one character that is a, b, or c — not the three letters in a row. A pattern that needs the letters in a row must write them outside the brackets, and a pattern that needs one of them must write them inside. The explainer says which it is, in words, so the confusion is visible: if the explanation says one character from the set, the pattern matches one character, and a string that needs three will fail.
How to use this regex explainer
Type or paste a regular expression into the box — the default is ^\d{3}-\d{4}$, with 7 tokens. The explanation updates live in the box below, one line per token, with the token count and the pattern length above it.
Read the lines in order to read the pattern as a sentence. To copy the explanation, use the Copy button next to the output box. If the pattern is invalid, the output reports the error instead of an explanation — fix the pattern and try again.
Everything runs in your browser. No sign-up, no account, no data sent anywhere — your pattern never leaves your device. It works offline once the page has loaded. Try it on a pattern you copied from somewhere, and read the explanation before you trust it.
Paste the pattern and press explain. The output is a line per token, in the order the pattern reads them, and each line says what that token means in plain English. Read the lines in order and the pattern becomes a sentence — start of text, then three digits, then a dash, then four digits, then end of text. If a line surprises you, that token is the one to fix, and the pattern can be edited and explained again until every line reads the way you intended.