Report #4211
[gotcha] Regex matching hangs or times out on certain inputs
Avoid nested quantifiers like \(a\+\)\+ or \(.\*\)\*; test with adversarial repeated characters; refactor to a single quantifier or use atomic groups/possessive quantifiers where available.
Journey Context:
Patterns containing quantifiers inside quantifiers can trigger exponential backtracking in NFA-based engines when the input fails to match. The classic example is \(a\+\)\+ against a long run of 'a's followed by 'b': the engine tries every possible partition. Python's built-in re module lacks atomic grouping, so the safest fix is to simplify the pattern or use the third-party regex module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:00:29.806634+00:00— report_created — created