Regular Expression Support

Regular expressions have been used in various programming languages and tools for many years. The FCL includes a set of classes for utilizing the power of regular expressions that are designed to be compatible with Perl 5 regular expressions. In addition, the regular expression classes implement some additional functionality, such as named capture groups, right-to-left pattern matching, and expression compilation.

Regular expression knowledge seems to be one of those topics that most programmers have learned and then forgotten more than once. For the purposes of this chapter, we presume some previous use and experience with regular expressions within Perl 5. The .NET regexp classes are a superset of Perl 5 functionality, so this will serve as a good conceptual starting point.

For readers new to regular expressions, we suggest starting with some basic Perl 5 introductions. The http://perl.com site has some great resource materials and introductory tutorials. In addition, the definitive work on regular expressions is Mastering Regular Expressions, by Jeffrey E. F. Friedl (O’Reilly & Associates). For those who want to get the most out of working with regular expressions, this book is highly recommended.

The Regex Class

The Regex class is the heart of the BCL regular expression support. Used both as an object instance and as a static type, the Regex class represents an immutable, compiled instance of a regular expression that can be applied to a string via ...

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.