Regular expression syntax summary
Here are some
basic elements of regular expressions in C#.
.
-
Match any character except a newline.
-
[…]
-
Match any of a set of characters. Characters may be listed
individually; for example,
[ace]
will match the
characters 'a', 'c', or 'e'. A set may also contain character
ranges; for example, [0-9a-dA-D]
will match any decimal
digit, the lowercase characters from 'a' to 'd', or the uppercase
characters from 'A' to 'D'. -
[^…]
-
Match any character that is
not in
the given set.
-
\d
-
Match any decimal digit.
-
\s
-
Match any whitespace character.
-
\w
-
Match any alphanumeric character, including underscores.
-
^
-
Anchor to the start of the source string.
-
$
-
Anchor to the end of the source string.
-
*
-
Match 0 or more repetitions of the preceding expression.
-
+
-
Match 1 or more repetitions of the preceding expression.
-
?
-
Match 0 or 1 repetitions of the preceding expression.
-
expr1
|
expr2 -
Matches either expr1 or expr2.
-
(…)
-
Indicates the start and end of a group.