I am trying to solve an scjp test about regex.
here is a code...
import java.util.regex.*;
public class TestRegex {
public static void main(String[] args) {
Pattern p = Pattern.compile(args[0]);
Matcher m = p.matcher(args[1]);
boolean b = false;
while (b = m.find()) {
System.out.print(m.start() + m.group());
}
}
}
and
java TestRegex "\d*" ab34ef
the answer for this test is 01234456
. I understood everything except the last output(6). Since the last index in "ab34ef" is 5, how is it possible to be printed 6 ?
Any help ....