Skip to main content
WizTools123
Free Online Tools

Tool Categories


Developer Tools New Tool

Free Online Regex Explainer and Pattern Builder

Paste a regular expression and read it back in plain English as a nested tree, with every group, character class, quantifier, anchor and backreference named. Or stack plain-language pieces into a pattern without typing regex syntax, and try it on your own sample text.

Free Forever Nothing Uploaded Explain or build Runs in your browser
Free Online Regex Explainer and Pattern Builder
Share this tool
Advertisement Slot (Top Banner) Google AdSense Unit • Responsive Banner
Regex Explainer & Builder Everything happens in this tab. Nothing you paste is sent anywhere.
Your regular expression
Explanation
Flags

Piece by piece

Try it on some text

-

Build one instead

Stack pieces in the order they should appear. Nothing here needs regex syntax.

Buy Us A Coffee

Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.

Buy Us A Coffee
Sponsored Content (Below Tool) Google AdSense Placement

The Six Flags, and What Each One Actually Changes

Most confusing regex behaviour is a flag that is on, or one that is not.

FlagNameWhat changes
g global Without it, String.replace changes the first match only and exec always returns the same match. With it, the expression carries a lastIndex that moves along, which is why reusing one global regex across two loops gives results that look random.
i ignoreCase Letters match in either case. It applies inside character classes too, so [a-z] with this flag also matches capitals, which is usually what people want and occasionally a nasty surprise.
m multiline Changes ^ and $ so they match at every line break rather than only at the two ends of the string. It does nothing to the dot.
s dotAll Lets . match a line break. This is the flag people reach for when a pattern stops working on a multi-line document, and it is the right one.
u unicode Turns on \u{...} and \p{...}, and makes the engine step over whole code points rather than 16-bit halves, so an emoji counts as one character instead of two.
y sticky The match must start exactly at lastIndex rather than anywhere at or after it. Useful when writing a tokeniser, misleading almost everywhere else.

If you paste a pattern with its slashes, such as /ab+c/gi, the slashes are stripped and the switches above are set to the flags you wrote, so you can paste straight out of a JavaScript file.

How to Read or Build a Regular Expression

A few steps, and nothing is uploaded.

1
Paste the pattern With or without the surrounding slashes. If you include flags after the closing slash, the switches are set to match.
2
Read the tree Each group, class, quantifier and escape is listed in the order the engine reads it, nested the way the pattern nests, with a plain sentence for each.
3
Try it on real text Paste a line or two into the test box for a match count and the first match. There is a full regex tester elsewhere on the site for anything more.
4
Or build one from pieces Stack plain-language pieces such as starts with, one or more digits, or an email address. The pattern appears as you go and can be sent to the box above.

What to Know About Regular Expressions

Including the parts that change from one language to the next.

This is the JavaScript flavour, and four differences catch people moving a pattern between languages. \d here is exactly the ten ASCII digits, while .NET and PCRE with Unicode enabled widen it to Arabic-Indic and other digits. Lookbehind exists in JavaScript and may be any length, but PCRE allows only a fixed length and older Safari has none at all. Named groups are (?<name>...) here and (?P<name>...) in Python. And PCRE's possessive quantifiers such as a++ and its atomic groups (?>...) simply do not exist in JavaScript, so a pattern that relies on them will not compile.
Greedy against lazy is behind almost every "it matched too much" report. <.+> on <a><b> matches the whole thing, because .+ takes everything it can and then gives characters back one at a time until the final > fits. Write <.+?> and it takes as little as possible and stops at the first >. Every quantifier in the tree above says which it is.
This explains and builds; it is not a full tester. There is a separate regex tester on this site for that work, so this page deliberately stops at one sample box, a match count and the first match. It does not show a table of capture groups per match, it does not preview a replacement, and it has no step-by-step view of how the engine backtracked.
The ready-made pieces are practical patterns, not definitions of the format. The email piece matches the shape of an address, which is all a regular expression can honestly do, since the full grammar in RFC 5322 allows comments and quoted strings that no sane pattern covers. The postcode, phone and URL pieces are the same: good enough to pick candidates out of text, not good enough to reject a real address someone owns.

Key Features & Capabilities

What this tool does, and what it deliberately does not.

A real nested tree The structure of the pattern, not a flat list of tokens in order.
Every part named Groups, classes, quantifiers, anchors, escapes and backreferences.
Greedy or lazy, stated Each quantifier says which it is and what the engine does because of it.
Build without syntax Stack plain-language pieces and read the pattern they produce.
No run button The tree, the match count and the built pattern update while you type.
Runs in your browser The parser is in this page. Nothing is uploaded and no API is called.

About the Regex Explainer

A regular expression is dense on purpose, and that is fine while you are writing one. It stops being fine two years later, when the pattern is in a validation rule nobody dares touch and the person who wrote it has left. This page reads the pattern back to you: what each piece matches, how the pieces nest, and where the engine will be generous or mean about how much it takes.

The hard part was refusing the easy route. Most "explain my regex" code matches tokens with another regular expression, which works on simple patterns and then quietly lies about nested groups, character classes that contain brackets, and escapes inside classes. This page has a small recursive parser instead, the same shape a real engine uses: alternation, then sequence, then quantifier, then atom. That is why the output is a tree with real depth rather than a list, and why an unclosed group is reported with the position where it opened.

The builder is the same idea running backwards. You choose pieces in plain language, each piece knows its own pattern and whether it needs wrapping before a quantifier can be applied to it, and the result is assembled with the brackets in the right places. It is sent straight into the box above, so the pattern you are building is explained and counted as you build it.

Frequently Asked Questions

Greedy and lazy, flavours, lookbehind and what this page will not do.

Almost always a greedy quantifier. .+ and .* take as much of the text as they can and then give it back one character at a time until the rest of the pattern fits, so a pattern with two of them tends to swallow whatever lies between. Add a question mark to make it lazy, or better, replace the dot with a class that cannot cross the boundary you care about, such as [^<]+ instead of .+.

You can paste it, and most of it will be explained correctly, but read the flavour note above first. Named groups use a different syntax in Python, possessive quantifiers and atomic groups do not exist in JavaScript at all, and inline flag groups such as (?i) are rejected here because JavaScript has no equivalent. Where something cannot work in this flavour the page says so rather than guessing.

A group consumes what it matches, so the engine carries on from after it. A lookahead checks that something is or is not there and then carries on from exactly where it was, consuming nothing. That is why \d+(?= kg) matches the number but leaves the unit out of the result, and why two lookaheads in a row both test the same position rather than testing one after the other.

Because non-capturing groups do not take a number, and capturing groups are numbered by the position of their opening bracket, counting from the outside in. The tree above numbers them exactly as the engine does, so if your group 2 is not what you thought it was, the tree will show you which bracket owns that number. Named groups are the cure: they keep working when someone adds a bracket in front of them.

No, and that is worth knowing. A pattern with nested quantifiers such as (a+)+b can take exponential time on the right input, which is how a regular expression becomes a denial of service. This page compiles your pattern and counts matches on your own sample, but it does not analyse it for catastrophic backtracking, and a sample that returns quickly here is not proof that some other input will.

Every Other Developer Tool

88 more tools in this set. All free, all in your browser.

Advertisement Slot (Bottom Banner) Google AdSense Unit • Responsive Banner