Background
The recently added regex filtering feature works well using Rust's regex crate. However, it does not support advanced regex features like lookarounds ((?=...), (?!...), etc.), which can be useful for more complex filtering scenarios.
This limitation was observed during usage and also discussed in #554.
Problem
Rust's regex crate intentionally does not support lookarounds due to performance guarantees (linear-time matching using NFA).
As a result, users cannot write certain expressive patterns that are commonly used in tools like grep.
Proposed Solution
Integrate fancy-regex as an optional or fallback engine:
- Use
regex crate for standard/simple patterns (fast path)
- Fallback to
fancy-regex when advanced features (like lookarounds) are detected
This approach aligns with how fancy-regex works internally — delegating simple cases to the fast NFA engine and handling complex patterns separately.
Benefits
- Enables support for lookarounds and other advanced regex features
- Maintains performance for common/simple patterns
- Improves usability for users familiar with grep-style filtering
Considerations
- Performance impact for complex patterns
- Need for pattern detection logic (to decide which engine to use)
- Additional dependency (
fancy-regex)
Next Steps
I will start implementing this and open a PR shortly.
cc: @beelze
Background
The recently added regex filtering feature works well using Rust's
regexcrate. However, it does not support advanced regex features like lookarounds ((?=...),(?!...), etc.), which can be useful for more complex filtering scenarios.This limitation was observed during usage and also discussed in #554.
Problem
Rust's
regexcrate intentionally does not support lookarounds due to performance guarantees (linear-time matching using NFA).As a result, users cannot write certain expressive patterns that are commonly used in tools like
grep.Proposed Solution
Integrate
fancy-regexas an optional or fallback engine:regexcrate for standard/simple patterns (fast path)fancy-regexwhen advanced features (like lookarounds) are detectedThis approach aligns with how
fancy-regexworks internally — delegating simple cases to the fast NFA engine and handling complex patterns separately.Benefits
Considerations
fancy-regex)Next Steps
I will start implementing this and open a PR shortly.
cc: @beelze