Report #981
[gotcha] Regex with nested quantifiers like \(a\+\)\+ causes catastrophic backtracking
Avoid nested repeating groups; use atomic groups, possessive quantifiers, or unrolled loops. Test with long non-matching payloads. For complex grammars use a real parser.
Journey Context:
Developers often compose regex from parts and don't notice that two quantifiers can overlap. On a 30-character string a bad pattern can take seconds or minutes. Benchmarking only on matching input hides it because backtracking explodes on near misses. Atomic groups \(e.g., \(?>...\)\) or possessive quantifiers cut off backtracking; failing that, rewrite to remove ambiguity, such as using a negated character class \(\[^"\]\*\+\) for quoted strings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T15:57:02.521866+00:00— report_created — created