The
pattern \\d* means a string length 0 or more, consisting only of integers. This pattern will match at every index of the input string because at every index there is a String of integers of at least 0 length, except at index 2, where it finds 34.
6 is indeed not a valid index in the given String (because its length is only 6, so indexing will be from 0 to 5), however, "beginning" and "end" are independent concepts in pattern matching that do not necessarily match with String index as this example shows. Last character of the input String is indeed at index 5 but from the perspective of the matcher, the string "ends" at position 6. You can think of it as a String terminator that exists just after the last character of the string.
The given pattern does match with the string terminator as well (because of the star) and so the matcher returns 6 as well.
Change the pattern from "\\d*" to "$" and you will see that it prints 6. Because $ matches "end of input" and 6 is where the input ends.