O'Reilly logo

C# 6.0 Cookbook, 4th Edition by Jay Hilyard, Stephen Teilhet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Regular Expressions

7.0 Introduction

The .NET Framework Class Library (FCL) includes the System.Text.RegularExpressions namespace, which is devoted to creating, executing, and obtaining results from regular expressions executed against a string.

Regular expressions take the form of a pattern that matches zero or more characters within a string. The simplest of these patterns, such as .* (which matches anything except newline characters) and [A-Za-z] (which matches any letter) are easy to learn, but more advanced patterns can be difficult to learn and even more difficult to implement correctly. Learning and understanding regular expressions can take considerable time and effort, but the work will pay off.

Note

Two books that will help you learn and expand your understanding of regular expressions are Michael Fitzgerald’s Introducing Regular Expressions and Jan Goyvaerts and Steven Levithan’s Regular Expressions Cookbook, both from O’Reilly.

Regular expression patterns can take a simple form—such as a single word or character—or a much more complex pattern. The more complex patterns can recognize and match such items as the year portion of a date, all of the <SCRIPT> tags in an ASP page, or a phrase in a sentence that varies with each use. The .NET regular expression classes provide a very flexible and powerful way to perform tasks such as recognizing text, replacing text within a string, and splitting up text into individual sections based on one or more complex delimiters. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required