Hi, I was going through K&B chapter-6 the following question:
Given:
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 the command line:
java Regex2 "\d*" ab34ef
What is the result?
A. 234
B. 334
C. 2334
D. 0123456
E. 01234456
F. 12334567
G. Compilation fails.
The answer to this question is : E.
Till 0123445 its clear to me but after that where this digit 6 is coming from because index 6 is not there in the input string.
Thanks