@Override public boolean isStartAnchored() { boolean anchored = true; for (Matcher m : matchers) { anchored &= m.isStartAnchored(); } return anchored; }
@Override public boolean isStartAnchored() { boolean anchored = true; for (Matcher m : matchers) { anchored &= m.isStartAnchored(); } return anchored; }
@Override public boolean isStartAnchored() { return matchers[0].isStartAnchored(); }
@Override public boolean isStartAnchored() { return matchers[0].isStartAnchored(); }
/** * If a start anchor is preceded by a repeated any match, then the any match can be removed * as it must be empty for the start anchor to match ({@code ".*^" => "^"}). */ static Matcher removeMatchAnyFollowedByStart(Matcher matcher) { if (matcher instanceof ZeroOrMoreMatcher) { ZeroOrMoreMatcher zm = matcher.as(); if (zm.repeated() instanceof AnyMatcher && zm.next() instanceof SeqMatcher && zm.next().<SeqMatcher>as().matchers().get(0).isStartAnchored()) { return zm.next(); } } return matcher; }
/** * If a start anchor is preceded by a repeated any match, then the any match can be removed * as it must be empty for the start anchor to match ({@code ".*^" => "^"}). */ static Matcher removeMatchAnyFollowedByStart(Matcher matcher) { if (matcher instanceof ZeroOrMoreMatcher) { ZeroOrMoreMatcher zm = matcher.as(); if (zm.repeated() instanceof AnyMatcher && zm.next() instanceof SeqMatcher && zm.next().<SeqMatcher>as().matchers().get(0).isStartAnchored()) { return zm.next(); } } return matcher; }