Regular Expressions

Parsing of text into a primitive value is easy enough using the various kinds of Parse methods. However, a more complex parsing task often needs to be accomplished. In that case, the BCL’s support for regular expressions enters the picture. Because regular expressions are a language of their own, we just touch on some of the capabilities, deferring a thorough discussion to MSDN once more.

The first thing to make sure when working with regular expression facilities is to have a using directive to import the System.Text.RegularExpressions namespace. When this is done, you have unqualified access to the Regex class, which is the entry point of the API. First, you create a new instance of this class, specifying the regular expression ...

Get C# 5.0 Unleashed 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.