Guides

Regex performance & catastrophic backtracking

Why some regexes explode on long inputs and how to rewrite them.

Related tools

Tip: open the tool page to see Pro batch/advanced modes.

What is catastrophic backtracking?

A common culprit is nested quantifiers like `(a+)+`, which can cause exponential backtracking.

Symptoms: small inputs work, large inputs suddenly hang.

Rewrite strategies

Avoid nested quantifiers; prefer specific character classes and boundaries.

Add anchors (^) ($) or length limits to prevent full scans when possible.