Regex Explainer
Explain what a regular expression matches, token by token, and flag the constructs that cause catastrophic backtracking.
🔒 This tool runs entirely in your browser. Your files are never uploaded to a server.
Developer
Regex Explainer
Frontend preview — no upload or external service.
Explanation
Anchored at start, captures one or more word characters, then @, then a host group, then a dot and a 2+ letter TLD, anchored at end. No nested quantifiers — safe from backtracking blowup.
How the Regex Explainer works
- Paste the expression, exactly as it appears in your code.
- Choose the flavour, since lookbehind and named groups differ between engines.
- Read the token breakdown, then the performance notes — nested quantifiers are the ones that matter.
FAQ
What is catastrophic backtracking?
A pattern where nested quantifiers create an exponential number of ways to match, so a slightly wrong input takes seconds or minutes. `(a+)+b` against a long run of a's is the classic example, and it is a real denial-of-service risk on user input.
Why do the same regexes behave differently between languages?
Because engines differ. Go's RE2 guarantees linear time and therefore drops backreferences and lookaround entirely; PCRE supports both and can backtrack catastrophically. The flavour matters.
Should I use regex for HTML or email?
For HTML, no — use a parser. For email, a simple pattern plus an actual verification message beats any attempt at RFC-complete validation, which is far harder than it looks.
How we compare
| Feature | Online Tool Store | A CLI script | An IDE plugin |
|---|---|---|---|
| Token-by-token explanation | ✓ | ✗ | ✓ |
| Backtracking warnings | ✓ | ✗ | Sometimes |
| Multiple engine flavours | ✓ | ✗ | ✓ |
| Pattern stays local | ✓ | ✓ | ✗ |
Regex Explainer reads the pattern and flags the nested quantifiers that turn a working expression into a denial-of-service risk on hostile input.