### Question:
Optimizer { static Matcher removeMatchAnyFollowedByIndexOf(Matcher matcher) { if (matcher instanceof ZeroOrMoreMatcher) { ZeroOrMoreMatcher zm = matcher.as(); if (zm.repeated() instanceof AnyMatcher && PatternUtils.getPrefix(zm.next()) instanceof IndexOfMatcher) { return zm.next(); } } return matcher; } private  Optimizer();   }### Answer:
@Test public void removeMatchAnyFollowedByIndexOf() { Matcher input = new ZeroOrMoreMatcher( AnyMatcher.INSTANCE, new IndexOfMatcher("foo", TrueMatcher.INSTANCE)); Matcher expected = new IndexOfMatcher("foo", TrueMatcher.INSTANCE); Assertions.assertEquals(expected, Optimizer.removeMatchAnyFollowedByIndexOf(input)); }