M
Marc E
All, given this code:
Pattern p = Pattern.compile("\\d*");
Matcher m = p.matcher("a");
while(m.find()){
System.out.println("start is " + m.start() );
}
Why is the output
0
1
?
I understand that start returns the index of the start of the search, but
given that this string is only one character, I don't understand how it gets
to an index of 1. does the start value of 1 indicate that it's actually
searching after the "a"?, i.e. that somehow find() is returning true after
it hits the end of the string?
Thanks for a clear explanation
Pattern p = Pattern.compile("\\d*");
Matcher m = p.matcher("a");
while(m.find()){
System.out.println("start is " + m.start() );
}
Why is the output
0
1
?
I understand that start returns the index of the start of the search, but
given that this string is only one character, I don't understand how it gets
to an index of 1. does the start value of 1 indicate that it's actually
searching after the "a"?, i.e. that somehow find() is returning true after
it hits the end of the string?
Thanks for a clear explanation