The regex
pattern \d* matches ZERO or MORE digits. The key thing to note is the ZERO possiblity.
m.find() Matcher class method definition: Attempts to find the next subsequence of the input sequence that matches the pattern.
m.start() Matcher class method definition: Returns the start index of the previous match.
m.group() Matcher class method definition: Returns the input subsequence matched by the previous match.
Upon the first iteration (b = m.find()) is set true because the * matches on ZERO digits found.
Imagine the
string as looking like this |0|
a|1|
b|2|
3|3|
4|4|
e|5|
f|6|
Where the bold characters are part of the string, and the numbers indicate an index
m.start() = 0 (The "space" behind the "a", I guess you could say. The darn * gets that I believe)
m.group() = ""
m.start() = 1
m.group() = ""
m.start() = 2
m.group() = "34" MATCH OCCURED!
The skip of the index occurs because the match covered the |3| index. Say it was "345" in the string then group would be "345" and m.start() would be 5 on the next iteration.
m.start() = 4
m.group() = ""
m.start() = 5
m.group() = ""
m.start() = 6
m.group() = ""
I believe this is how it works anyway...I ran a quick test with the same pattern trying to match "" and it came back with m.start() with index 0!