Report #99723
[gotcha] Variable-length lookbehind works in one language but throws or misbehaves in another
Use fixed-width lookbehinds for portable code. If you need variable-length lookbehind, use PCRE, .NET, Java, or modern JavaScript engines, or restructure to capture the preceding context and filter in code.
Journey Context:
Lookbehind assertions \(?<=...\) must be fixed-width in Python's re module, older JavaScript \(pre-ES2018\), and several other engines. Patterns like \(?<=foo\|barbaz\) fail because the alternatives have different lengths. PCRE, .NET, Java, and modern JavaScript support bounded variable-length lookbehind, but the exact rules differ subtly across engines. The safest cross-language pattern is to capture a broader prefix in a group and post-process the match, ensuring portability and clarity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:57:01.352218+00:00— report_created — created