Regular Expressions Language Elements
Quantifiers add optional quantity data to a regular expression. A quantifier expression applies to the character, group, or character class that immediately precedes it. The .NET Framework regular expressions support minimal matching ( lazy ) quantifiers.
The following table describes the metacharacters that affect matching quantity.
Quantifier |
Description |
* |
Specifies zero or more matches; for example, \w* or ( abc ) *. Same as {0,}. |
+ |
Specifies one or more matches; for example, \w+ or ( abc ) +. Same as {1,}. |
? |
Specifies zero or one matches; for example, \w? or ( abc ) ?. Same as {0,1}. |
{n} |
Specifies exactly n matches; for example, ( pizza ) {2}. |
{n,} |
Specifies at least n matches; for example, ( abc ) {2,}. |
{n,m} |
Specifies at least n, but no more than m, matches. |
+? |
Specifies the first match that consumes as few repeats as possible ( Lazy * ). |
+? |
Specifies as few repeats as possible, but at least one ( Lazy + ). |
?? |
Specifies zero repeats if possible, or one ( Lazy ? ). |
{n}? |
Equivalent to {n} ( Lazy {n} ). |
{n,}? |
Specifies as few repeats as possible, but at least n ( Lazy {n,} ). |
{n,m}? |
Specifies as few repeats as possible, but between n and m ( Lazy {n,m} ). |
ASP.NET Page Syntax
|