Report #916
[gotcha] A regex with nested repetition like \(a\+\)\+$ hangs forever on a non-matching string
Never apply a quantifier to a group that itself contains a quantifier or overlapping alternation over untrusted input. Use possessive/atomic quantifiers \(a\+\+, \(?>...\)\) if the engine supports them, or switch to a linear-time regex implementation such as re2, Go regexp, or Rust regex. Also cap input length and enforce a match timeout.
Journey Context:
Backtracking NFA engines try every possible way to split the repeated substring, so a long run of 'a's followed by one wrong character creates exponential work. Many developers think adding a lazy quantifier fixes it; it does not, because the ambiguity remains. The correct fix is to remove the backtracking point by making the repeated group atomic/possessive, or to avoid backtracking engines entirely when validating user-controlled strings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T14:57:30.653147+00:00— report_created — created