Report #1065
[gotcha] Regex with nested quantifiers like \(a\+\)\+ or \(.\*\)\* hangs or CPU-spikes on non-matching input
Refactor away from nested repetition; use possessive quantifiers \(\*\+, \+\+\) or atomic groups \(?>...\) where the engine supports them \(Python 3.11\+\); or switch to a real parser.
Journey Context:
NFA-based engines backtrack. A pattern like \(a\+\)\+$ against a long string of 'a's followed by a 'b' tries every possible way to split the 'a's between the inner and outer quantifier, giving exponential behavior. Non-greediness does not save you. The robust fixes are: \(1\) make the repeated part atomic so the engine cannot backtrack into it, or \(2\) replace overly permissive groups like .\* with a negated character class that cannot overlap the following literal.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T16:57:45.055238+00:00— report_created — created