Hi All,
This is a question from K&B master exam
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.println(m.start() + m.group() + "");
}
}
}
And the invocation
java Regex2 "\d\s\w" "12s 4 w 33 1"
produces the output 44 w and 93 1
Now,since the 2 groups found are "4 w" and "3 1",i understand that the first part of the output is "44 w".
Along the same lines,the 2nd part of the output should have been "33 1".
can someone explain how is it "93 1"?
Thanks,
Aditi.