Appendix B. Regular Expressions
The following tables summarize the regular expression grammar
and syntax supported by the regular expression classes in System.Text.RegularExpressions
. 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).
All the syntax described in Table B-1 through Table B-10 should match the Perl5 syntax, with specific exceptions noted.
Escape Code Sequence | Meaning | Hexadecimal equivalent |
\a | Bell | \u0007 |
\b | Backspace | \u0008 |
\t | Tab | \u0009 |
\r | Carriage return | \u000D |
\v | Vertical tab | \u000B |
\f | Form feed | \u000C |
\n | Newline | \u000A |
\e | Escape | \u001B |
\040 | ASCII character as octal | |
\x20 | ASCII character as hex | |
\cC | ASCII control character | |
\u0020 | Unicode character as hex | |
\ non-escape | A nonescape character |
Special case: within a regular expression, \b
means word boundary, except in a []
set, in which \b
means the backspace character.
Expression | Meaning |
$ | Substitutes last substring matched by
|
${ | Substitutes last substring matched by |
$$ | Substitutes a literal “$” |
$& | Substitutes copy of the entire match |
$' | Substitutes text of the input string preceding match |
$' | Substitutes text of the input string following match |
$+ | Substitutes the last captures group |
$_ | Substitutes the entire input string |
Substitutions are specified only ...
Get C# Essentials, 2nd 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.