The DOS/Windows style CRLF ends of lines might be changed to Unix style LF ends of lines.
Decent text editors give you control over this, but you need to know that it might happen.
|Group 1||Group 2||Group 3||Group 4|
A capture group in an RE is a sub-expression surrounded by parentheses. Here is a RE containing a capture group:
If the RE matches a substring, then that substring is Group 0.
The part of the substring that matches the first capture group is "captured" (stored in an object) and may be used later. That part is Group 1.
Java programs may access the data in a capture
group after the matching has been done.
This is explained further in the chapters on
String and class
Play with the applet. Change what part of the expression is surrounded by parentheses to change what part of the string is captured. You can put in additional sets of parentheses to form additional capture groups.
Details: The parentheses must surround a legal subexpression. It is OK if they surround the entire expression, this just means that the entire match will be group 1 (in addition to being group 0).
If a quantifier is placed to the right of a capture group,
([0-9])+ then the last substring
matched by the group will be captured.
(This will be the last digit matched, in this example.)
Is this expression