Report #97856
[gotcha] Lookbehind assertion with variable-width pattern fails or throws
In Python's standard \`re\` module, lookbehind must be fixed-width; use the third-party \`regex\` module, refactor the pattern into a lookahead, or capture and inspect the preceding text in application code. In JavaScript, variable-width lookbehind requires ES2018\+ support.
Journey Context:
Many developers assume lookbehind works like lookahead. Python's \`re\` and older JavaScript engines enforce fixed-width lookbehind because the engine must know exactly how many characters to step back. Patterns like \`\(?<=ab\|c\)\` or \`\(?<=\\w\{1,3\}\)\` are therefore invalid in Python \`re\`. The \`regex\` module removes this restriction, and modern ECMAScript added variable-width lookbehind in 2018.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:49:07.427014+00:00— report_created — created