Standard Meta Characters
Backreferences (continued)
You can use parentheses to group things for quantifiers, but you can also use them to remember pieces of what you have already matched. That is, a pair of parentheses around a part of a regular expression causes the string's portion that was matched by that part, to be remembered for later use. Take a look at the following regular expressions:
Both regular expressions match as many digits as possible, but in the latter case they will be remembered in a special variable so they can be backreferenced later. |