(question 1 of chapter 6
test)
import java.util.regex.*;
class Regex2 {
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 command line:
java Regex2 "\d*" ab34ef
Answer gives result of 01234456 (option E).
I get 0123445. How can m.start() return 6 when the source only has 6 elements?
Ken Truitt