Regex Explainer
Paste any regex and get a plain-English explanation of every part.
Highlighted Pattern
Token Breakdown
Color Legend
About Regex Explainer
This tool tokenizes any regular expression and describes each component in plain English. It handles anchors (^ and $), quantifiers (*, +, ?, {n,m}), character classes such as [a-z], \d, and \w, capturing and non-capturing groups, positive and negative lookaheads, the wildcard dot, alternation (|), word boundaries (\b), and common escape sequences. Paste a pattern, optionally enter a test string to see MATCH, NO MATCH, or INVALID, and click any preset from the library to load a common pattern. All processing runs entirely in your browser — nothing is sent to a server.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Understanding an inherited pattern nobody documented.
- Checking that a pattern does what its author claimed.
- Learning regex syntax by reading explanations of real patterns.
- Reviewing a pattern in a pull request without running it mentally.
- Working out why a pattern matches more than expected.
Frequently Asked Questions
- What does a plain-English explanation help with?
- Reading someone else's pattern. Writing a regex is usually easier than verifying one, and a description that names each construct is faster to check against intent than mentally executing the pattern character by character.
- What is the difference between greedy and lazy?
- `.*` takes as much as it can and backtracks; `.*?` takes as little as possible and expands. On `<a><b>` the greedy `<.*>` matches the whole string while the lazy `<.*?>` matches just `<a>` — which is the single most common surprise in regex behaviour.
- What do lookahead and lookbehind actually do?
- Assert without consuming. `foo(?=bar)` matches `foo` only when followed by `bar`, and the `bar` is not part of the match. That zero-width property is what makes them useful for splitting and replacing at positions rather than on content.
- Why does the same pattern behave differently in two languages?
- Because the flavours differ. PCRE, JavaScript, Python, Go's RE2 and POSIX all vary on lookbehind support, named groups, Unicode properties and whether backtracking is permitted at all — RE2 deliberately excludes backreferences to guarantee linear time.
- What is catastrophic backtracking?
- Nested quantifiers like `(a+)+b` producing exponential work on an input that nearly matches. On a server it is a denial-of-service class with its own CVE history, which is why RE2 and Rust's regex crate refuse the constructs that allow it.
Common errors and gotchas
- Trusting the explanation over testing, since a description can be right and the pattern still wrong for your input.
- Assuming one flavour, where lookbehind and named groups differ by engine.
- Overlooking flags, which change the meaning of anchors and the dot entirely.
- Missing catastrophic backtracking, which an explanation does not reveal.
- Reading an explanation of the pattern rather than of the pattern plus its flags.