Report #4214
[gotcha] Variable-length lookbehind assertion causes error or unexpected behavior
In Python re and similar engines, lookbehind must be fixed-width; rewrite using a capture group and post-check, or use an engine that supports variable-width lookbehind such as the regex module or .NET.
Journey Context:
Many engines implement lookbehind by stepping back a fixed number of characters. Python's re module rejects patterns like \(?<=ab\|abc\) because the alternatives have different lengths, raising 'look-behind requires fixed-width pattern'. JavaScript ES2018 relaxed this but still prohibits variable-length lookbehind with backreferences, so porting patterns across engines silently fails.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:00:30.208842+00:00— report_created — created