/** * Walks forward with the caret until it points at a position which matches the given string. * Case-Insensitive comparison is used. * * @param strToMatch * the string to match * @return true if the string was found, false if the end of the string was reached while * searching */ public boolean walkToMatchIgnoreCase(String strToMatch) { while (!endReached() && !startsWithIgnoreCase(strToMatch)) { offset++; } return !endReached(); }
@Test public void test() { String test = " ABCDEFGH\t\r\nabcdefg"; Caret c = new Caret(test, 4); assertThat(c.startsWithIgnoreCase("def"), equalTo(false)); assertThat(c.startsWithIgnoreCase("cdef"), equalTo(true)); assertThat(c.startsWithIgnoreCase("CDEF"), equalTo(true)); } }