go to previous page   go to home page   go to next page

([a-z]*([0-9]*))(X+)

Answer:

Three groups. Group 0 does not count. Groups can be nested withing groups.

Review: to determine the number of a group, scan the expression left to right. The first left parenthesis starts group 1, the second left parenthesis starts group 2, and so on. Of course, each left parenthesis must have a matching right parenthesis which shows the end of the group.

No Group before a Match

The groups of the Matcher are filled in during the matching process. If no match has been performed, there is no group data. If a group() method is called before a match, an IllegalStateException is thrown.


QUESTION 13:

Do you always want to match an entire string?