Appendix A. Regular Expressions
The following
tables
summarize the regular-expression grammar and syntax supported by the
regular-expression classes in
System.Text.RegularExpression
. Each of the
modifiers and qualifiers in the tables can substantially change the
behavior of the matching and searching patterns. For further
information on regular expressions, we recommend the definitive
Mastering Regular Expressions by Jeffrey E. F.
Friedl (O’Reilly & Associates, 1997).
All the syntax described in the tables should match the Perl5 syntax, with specific exceptions noted.
Table A-1. Character escapes
Escape code sequence |
Meaning |
Hexadecimal equivalent |
---|---|---|
|
Bell |
|
|
Backspace |
|
|
Tab |
|
|
Carriage return |
|
|
Vertical tab |
|
|
Form feed |
|
|
Newline |
|
|
Escape |
|
|
ASCII character as octal | |
|
ASCII character as hex | |
|
ASCII control character | |
|
Unicode character as hex | |
|
A nonescape character |
Special case: within a regular expression, \b
means word boundary, except in a [ ]
set, in which
\b
means the backspace character.
Table A-2. Substitutions
Expression |
Meaning |
---|---|
|
Substitutes last substring matched by group-number |
|
Substitutes last substring matched by
( |
Substitutions are specified only within a replacement pattern.
Table A-3. Character sets
Expression |
Meaning |
---|---|
. |
Matches any character except \n ... |
Get C# in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.