|Group 1||Group 2||Group 3||Group 4|
An expression may contain several capture groups, numbered group 0, group 1, group 2 and so on. Group 0 corresponds to the substring that matched the entire regular expression. You may have any number of groups (although the applet shows only zero through four.)
The parentheses that surround the groups in an expression must be balanced. Groups can be nested, so a group can have groups within it.
Groups are numbered from left to right starting with number one for the group formed by the leftmost parenthesis and the right parenthesis it matches.
Group number two is the group formed by the next left parenthesis and the right parenthesis that it matches, and so on. Here is an example of group numbering:
If the entire expression is surrounded by parentheses, then group0 and group1 correspond to the same matched substring.
Is the following expression correct?