DevTools Hub

Search tools

Search for a developer tool

Development

Regex Debugger

Step through a regex match attempt and catch catastrophic backtracking before it ships.

//
Try an example:
Debugs one match attempt starting here — not a full scan like the Regex Tester.
Position in string
contact: bob@example
Matched "bob@example" at index 9 (18 steps)
$1 = "bob"
$2 = "example"
Step trace (15)
  • pos 9Enter group 1
  • pos 9Match \w (any word character (letter, digit, underscore))
  • pos 10Match \w (any word character (letter, digit, underscore))
  • pos 11Match \w (any word character (letter, digit, underscore))
  • pos 12Match \w (any word character (letter, digit, underscore))
  • pos 12Match literal "@"
  • pos 13Enter group 2
  • pos 13Match \w (any word character (letter, digit, underscore))
  • pos 14Match \w (any word character (letter, digit, underscore))
  • pos 15Match \w (any word character (letter, digit, underscore))
  • pos 16Match \w (any word character (letter, digit, underscore))
  • pos 17Match \w (any word character (letter, digit, underscore))
  • pos 18Match \w (any word character (letter, digit, underscore))
  • pos 19Match \w (any word character (letter, digit, underscore))
  • pos 20Match \w (any word character (letter, digit, underscore))

Hover a step to see its position highlighted in the string above.

Watching a match happen, step by step

JavaScript's native RegExp gives you a yes/no answer and, if you're lucky, a match object — it doesn't explain why a pattern failed or show you the backtracking that happened along the way. This tool runs its own small backtracking engine that mirrors how the real one works, and logs every attempt: which piece of the pattern was tried, at what position in the string, and whether it matched, failed, or triggered a backtrack.

It debugs one match attempt from a given starting position, rather than scanning the whole string for every match — that's what makes it a debugger rather than a duplicate of the Regex Tester. Move the start position to inspect exactly what happens if the engine tried to match somewhere else.

Catching catastrophic backtracking before it ships

Some patterns don't just fail slowly on certain input — they can take exponentially longer as the input grows, hanging whatever process is running them. This tool does two things about that: it statically flags risky shapes (nested unbounded quantifiers like (a+)+, or a repeated alternation like (a|ab)+) before you even run a match, and it caps its own execution at a step budget — so if a pattern really is exponential on your test input, you'll see an explicit "aborted" result instead of a frozen tab. Click the "Catastrophic" example above to see it happen on a small, safe input.

For the reasoning behind why these shapes are dangerous and how to rewrite them, see Regex Performance Tips.

Reading the trace

FAQ

Why doesn't this scan the whole string like the Regex Tester does?

Because debugging is about understanding one specific attempt in detail. If you want to see every match across a string, use the Regex Tester — this tool is for when you already know roughly where a match should (or shouldn't) happen and want to see exactly why.

Does the character-class matching reimplement JavaScript's regex engine?

Only the structural part — groups, alternation, quantifiers, and backtracking — is a custom engine built for this tool. Character class and dot matching defer to the browser's own RegExp for a single character at a time, so classes like \d or [a-z] behave exactly as JavaScript defines them.

Related tools