(→Precedence) |
(→Precedence) |
||
| Line 23: | Line 23: | ||
The order of precedence of the regular expressions operators is: | The order of precedence of the regular expressions operators is: | ||
| − | + | Highest > (to) Lowest | |
| − | + | '''\\''' > '''[ ]''' > '''* + ?''' > '''{ }''' > '''Concatenations''' > '''|''' | |
==Groups and Replacement Examples== | ==Groups and Replacement Examples== | ||
==Related Resources== | ==Related Resources== | ||
The special symbols “{” and “}” group regular expressions for reference purposes. They permit the text matched by the expression within “{ }” to be referenced again in the search string or to be included as part of the replacement text.
An expression may contain up to 9 groups which are referenced by number, “\1” through “\9”. The groups are numbered in the order of their opening “{”.Groups may also be nested. Groups may be referenced in either a latter part of the regular expression or in the replacement string. This allows portions of the matched text to be used as parts of the replacement text.
The character “&” has a special meaning only in a replacement string and references the entire text matched by the search.
Consider the expression “the {man}|the {woman}”. If the matched text is “the man”, “\1” is “man” and “\2” is empty (null). Now consider the expression “{the {[a-z]+}} has”. If the matched text is “the woman has”, “\1” is “thewoman” and “\2” is “woman”.
The order of precedence of the regular expressions operators is:
Highest > (to) Lowest \\ > [ ] > * + ? > { } > Concatenations > |