public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) { int rightBound = matchResult.hasAnchoringBounds() ? matchResult.getRightBound() : testString.length(); if (strIndex >= rightBound) { matchResult.setConsumed(consCounter, 0); return next.matches(strIndex, testString, matchResult); } // check final line terminator; if ((rightBound - strIndex) == 1 && testString.charAt(strIndex) == '\n') { matchResult.setConsumed(consCounter, 1); return next.matches(strIndex + 1, testString, matchResult); } return -1; }