Lookaround is the most fragmented feature in regex
You'd think "look around the position" would be universal. It isn't. Here's the actual landscape as of 2026:
| Engine | Lookahead | Lookbehind | Variable-width Lookbehind |
|---|---|---|---|
Python re | ✓ | ✓ | ✗ (raises error) |
Python regex | ✓ | ✓ | ✓ |
| JavaScript | ✓ | ✓ (ES2018) | ✓ (ES2018) |
| PCRE | ✓ | ✓ | Partial (depends on version) |
| Java | ✓ | ✓ | Limited (max length must be bounded) |
| .NET | ✓ | ✓ | ✓ |
Go regexp / RE2 | ✗ | ✗ | ✗ |
| ripgrep (default) | ✗ | ✗ | ✗ |
ripgrep --pcre2 | ✓ | ✓ | Partial |
The portability spectrum
Universal: No lookaround. Use anchors and character classes only.
Most engines: Lookahead (positive and negative). Almost always supported.
Most engines, but quirky: Lookbehind, fixed-width. Python, Java, .NET. Watch the width rule.
Modern engines only: Variable-width lookbehind. JavaScript ES2018+, .NET, Python regex.
Never: Go, RE2. Patterns using lookaround simply won't compile.
Practical advice
If your code needs to run in multiple languages or your regex might end up in a Go service, avoid lookaround. Use anchors, captures, and post-processing. The pattern is uglier but portable.
If you're in one engine and stay there, use lookaround freely — it's the cleanest tool for many problems.