Report #3224
[gotcha] Negative or positive lookbehind with variable-length alternatives raises an error or behaves differently across engines
Keep lookbehind patterns fixed-width in engines that require it \(Python re, PCRE, Java before recent versions\). If you need variable-length context, use a workaround: anchor a negative lookahead at the start with '^\(?\!.\*bad\)', use '\\K' with a preceding match, or capture the candidate and filter in code. In JavaScript, confirm the runtime supports lookbehind \(ES2018\+\) before using it.
Journey Context:
Many regex engines restrict lookbehind to fixed-length patterns because matching backwards with variable-length alternatives is ambiguous and expensive. Python's re module enforces this explicitly. JavaScript added lookbehind in ES2018 but older Node/Browsers throw SyntaxError. The usual trap is writing '\(?
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T15:53:19.186641+00:00— report_created — created