### Question:
Optimizer { static Matcher convertRepeatedAnyCharSeqToIndexOf(Matcher matcher) { if (matcher instanceof ZeroOrMoreMatcher) { ZeroOrMoreMatcher zm1 = matcher.as(); Matcher prefix = PatternUtils.getPrefix(zm1.next()); if (zm1.repeated() instanceof AnyMatcher && prefix instanceof CharSeqMatcher) { String pattern = prefix.<CharSeqMatcher>as().pattern(); Matcher suffix = PatternUtils.getSuffix(zm1.next()); return new IndexOfMatcher(pattern, suffix); } } return matcher; } private  Optimizer();   }### Answer:
@Test public void convertRepeatedAnyCharSeqToIndexOf() { Matcher input = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create( new CharSeqMatcher("abc"), new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create( new CharSeqMatcher("def"), new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, TrueMatcher.INSTANCE) )) )); Matcher expected = SeqMatcher.create( new IndexOfMatcher( "abc", new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, SeqMatcher.create( new CharSeqMatcher("def"), new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, TrueMatcher.INSTANCE) )) ) ); Assertions.assertEquals(expected, Optimizer.convertRepeatedAnyCharSeqToIndexOf(input)); }