Description
A lookahead assertion ((?=...) or (?!...)) inside a quantified group (e.g. (?:(?=\d)\d)+) does not work correctly. The pattern matches nothing regardless of input.
Reproduction
ReggieMatcher m = Reggie.compile("(?:(?=\\d)\\d)+");
m.find("123"); // returns false — WRONG, should be true
m.find("abc"); // returns false — correct, but for wrong reason
Root cause
The DFA_UNROLLED_WITH_ASSERTIONS strategy does not correctly handle lookahead assertions nested inside quantified groups. The lookahead state is not re-evaluated on each iteration of the quantified loop.
Current mitigation
FallbackPatternDetector detects a lookahead AssertionNode inside a QuantifierNode's subtree and falls back to java.util.regex.
Fix direction
When a quantified group contains a lookahead, the assertion must be re-evaluated from the current position on each iteration of the loop in the generated bytecode.
Impact
High — patterns that use lookahead constraints inside repeated groups silently produce wrong results.
Description
A lookahead assertion (
(?=...)or(?!...)) inside a quantified group (e.g.(?:(?=\d)\d)+) does not work correctly. The pattern matches nothing regardless of input.Reproduction
Root cause
The
DFA_UNROLLED_WITH_ASSERTIONSstrategy does not correctly handle lookahead assertions nested inside quantified groups. The lookahead state is not re-evaluated on each iteration of the quantified loop.Current mitigation
FallbackPatternDetectordetects a lookaheadAssertionNodeinside aQuantifierNode's subtree and falls back tojava.util.regex.Fix direction
When a quantified group contains a lookahead, the assertion must be re-evaluated from the current position on each iteration of the loop in the generated bytecode.
Impact
High — patterns that use lookahead constraints inside repeated groups silently produce wrong results.