|
|
Alternation A regular expression can contain a list of subexpressions, anyone of which might match the target. The list of subexpressions is delimited by "|"
Example
Since regular expressions are greedy (ie they match the longest possible first match), the alternation metacharacter operates on the largest possible surrounding regular expression. More technically, the alternational metacharacter has the lowest precedence of any regular expression operator.
Example To limit alternation, grouping brackets can be used.
Example
|
|
||||||||||||||||||