For anchored matches, break out of the search loop on encountering the first character not in a pattern