I tried coding the problem and running it with the specified command line.
I got the following : 01234456
I tried running a different command line :
java Regex2 "\w*" ab34ef
I got the following : 0ab34ef6
the m.start() method prints 0 and the m.group() method prints ab34ef. After ab34ef are consumed, m.start() prints 6 for the linefeed and m.group() prints the empty string.
It looks as if the matcher() is including the linefeed at the end of the character string.