This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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 as the String to be examined, and \d\w which is args 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.
Joined: Dec 15, 2007
hey thanks for that link.... but i could not find any pattern() in Matcher class... then how is it used...???