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.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
The Six Flags, and What Each One Actually Changes
Most confusing regex behaviour is a flag that is on, or one that is not.
| Flag | Name | What 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.
What to Know About Regular Expressions
Including the parts that change from one language to the next.
\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.
<.+> 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.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
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.
.+ 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 .+.(?i) are rejected here because JavaScript has no equivalent. Where something cannot work in this flavour the page says so rather than guessing.\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.(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.