Regular Expressions

Learn how to process text and validate patterns efficiently using regular expressions in .NET.

A .NET application can use the power of regular expressions out of the box. Regular expressions are a versatile and effective way to process large texts.

Note: Regular expressions require a separate course of their own because of their complexity. This lesson only provides a brief overview.

We can use them to find substrings that match a certain condition. We can also check whether a string object conforms to specific rules, such as a correct phone number format. Regular expressions require far less code to address these tasks than the built-in methods of the System.String and StringBuilder classes.

Finding matches using string methods

Suppose we need to find all words containing the "or" substring within a large block of text. We can implement a solution using standard string methods.

Here is a traditional approach using manual iteration.