Regular Expressions

Table 1-7 through Table 1-16 summarize the regular-expression grammar and syntax supported by the regular-expression classes in System.Text.RegularExpressions. (For more information, see the “.NET Framework Regular Expressions” topic in the .NET Framework SDK Documentation.) 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, 2002).

All the syntax described in the tables should match the Perl5 syntax, with specific exceptions noted.

Table 1-7. Character escapes

Escape code sequence


Hexadecimal equivalent











Carriage return



Vertical tab



Form feed









ASCII character as octal


ASCII character as hex


ASCII control character


Unicode character as hex

\ non-escape

A nonescape character

As a special case: within a regular expression, \b means word boundary, except in a [ ] set, in which \b means the backspace character.

Table 1-8. Substitutions



$ group-number

Substitutes last substring matched by group-number

${ group-name }

Substitutes last substring matched by (?< group-name >)

Substitutions are specified ...

Get C# Language Pocket Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.