Regular Expressions Language Elements
The following table lists special characters that modify a regular expression to allow either/or matching.
Alternation construct |
Definition |
| |
Matches any one of the terms separated by the | character; for example, cat | dog | tiger. The leftmost successful match wins. |
( ? ( expression ) yes | no ) |
Matches the "yes" part if the expression matches at this point; otherwise, matches the "no" part. The "no" part can be omitted. The expression can be any valid subexpression, but it is turned into a zero-width assertion, so this syntax is equivalent to ( ? ( ?=expression ) yes | no ). Note that if the expression is the name of a named group or a capturing group number, the alternation construct is interpreted as a capture test ( the next case ). To avoid confusion in these cases, you can spell out the inside ( ?=expression ) explicitly. |
( ? ( name ) yes | no ) |
Matches the "yes" part if the named capture string has a match; otherwise, matches the "no" part. The "no" part can be omitted. If the given name does not correspond to the name or number of a capturing group used in this expression, the alternation construct is interpreted as an expression test ( the previous case ). |
ASP.NET Page Syntax
|