Report #930
[gotcha] Variable-length lookbehind causes a compile error or unexpected match behavior
Keep lookbehind assertions fixed-width in Python re and PCRE \(e.g., \(?<=abc\) or \(?<=a\|bc\)\). If you need variable-length lookbehind, capture a broader prefix and filter in code, use \\K in PCRE, or switch to an engine that supports it such as the third-party Python regex module, PCRE2, or .NET.
Journey Context:
Lookbehind is often treated like lookahead, but many engines require the pattern inside to match a fixed number of characters. Writing \(?<=foo\\s\+\) or \(?<=\\d\{1,3\}\) raises 'look-behind requires fixed-width pattern' in Python and similar errors elsewhere. The cleanest portable solution is to match the surrounding context explicitly and inspect it after the match, or use a more capable engine when that is acceptable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T14:59:30.598483+00:00— report_created — created