Report #1861
[gotcha] Regex with nested quantifiers causing exponential backtracking
Avoid patterns like \(a\+\)\+, \(.\*\)\+, or nested groups with overlapping alternatives. Use possessive quantifiers \(\+\+ or \*\+\), atomic groups \(\(?>...\)\), or refactor to non-overlapping alternatives. In Python use the regex module or re with carefully bounded patterns.
Journey Context:
A pattern such as /^\(\\d\+\)\+$/ against a long non-matching string can hang for seconds or minutes because the engine tries every partition of the input. This is not a regex-engine bug; it is fundamental to NFA backtracking. The common mistake is using .\+ inside a group that is itself repeated. The fix is to make quantifiers mutually exclusive or use atomic/possessive quantifiers to prevent backtracking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T08:51:47.622406+00:00— report_created — created