Have you been through the
Java Tutorial about regular expressions?
Your 2nd
pattern is obviously matching two or more digits, then starting when it finds something which is not a digit. So 335 matches on the 33, then the 5f doesn't match, then the 45 matches, then the 6, being a single digit, doesn't match.
Your first example uses args[1] as the
String to be examined, and \d\w which is args[0] as the pattern/regular expression to
test against. You can see at the bottom, you printed out \d\w as the pattern. Now \d\w means a digit followed by a "word character." You can find what "word characters" are from the link I quoted; look for "predefined character classes." So at position 4 (ie the 5th character) it found its 1st combination of a digit and a
word character, 56. _7 doesn't count, but 7a is the next place where there is a digit followed by a "word character."
Read the link I quoted; it is nice and easy to understand.