Report #372
[gotcha] Negative lookahead excludes the wrong text or negative lookbehind is rejected
Use lookahead \(?\!...\) to assert what follows the current position and lookbehind \(?
Journey Context:
Developers often confuse direction: \(?\!foo\) succeeds whenever 'foo' is not immediately ahead, not whenever the string lacks 'foo'. Lookbehind is the tool for checking the prefix, but many engines require the lookbehind subpattern to have a fixed length so the engine knows how far to step back. Python and JavaScript support only fixed-width lookbehind; PCRE and .NET allow variable length; RE2 allows none. The portable fallback is to capture the candidate and apply the prefix/exclusion test in ordinary code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T05:42:20.447145+00:00— report_created — created