deftools.io Developer Tools

Regex Explainer

Decode any regex into plain English — paste a pattern and see every token explained: anchors, quantifiers, character classes, groups. Understand what a regex matches without running it.

/ /
Examples:
Enter a pattern above and click Explain.

About this tool

A regular expression can look like keyboard mash — ^(\d3)-(\d3)-(\d4)$ is a phone-number pattern, but you would not know it from the glyphs. This explainer walks the pattern character by character and tells you, in plain English, what each piece matches: anchors, character classes, quantifiers, capture groups, lookarounds, and more. Paste a regex you found in code, in a config file, or in a Stack Overflow answer, and read what it does without running it.

Example: ^https?://([^/]+)(/.*)?$ breaks down as — ^ anchor to start, http literal, s? optional "s", :// literal, then capture group #1 of one-or-more non-slash chars (the host), then capture group #2 of .* optional path, ending with $ anchor. The summary line says: matches the whole string, with 2 capture groups.

Switch the example chips to see URL, email, time, repeated-word, and named-group patterns parsed. Each token is color-coded by role (anchor, class, quantifier, group, alternation) so the structure is visible at a glance.

FAQ

Why does my regex show a syntax error here when it works elsewhere?

JavaScript regex syntax is what this tool parses. Patterns using PCRE-only features (atomic groups (?>...), possessive quantifiers in older engines, named backreferences via \k<name> without the /u flag, or recursive (?R) subpatterns) will be flagged. Most day-to-day patterns work identically across engines.

What is the difference between (a) and (?:a)?

Parentheses with no prefix create a capturing group: the matched text is stored and available later as $1, $2, etc. Adding ?: makes it non-capturing — the parentheses group the pattern but do not remember the match. Use (?:...) when you only need grouping (e.g. for a quantifier) and do not care about the captured value.

What are lookahead and lookbehind?

Lookarounds assert that something does (or does not) match at the current position, without consuming characters. (?=ab) means "next chars must be ab"; (?!ab) means "next chars must NOT be ab"; (?<=ab) means "preceded by ab"; (?<!ab) means "NOT preceded by ab". They are useful for matching only in a specific context.

Can this tool test if my regex matches a string?

No — this is a static explainer. To actually test matches against text, capture groups, and replacements, use the Regex Tester tool which runs your pattern live and highlights results.

More developer tools

Copied!