TOC

The community is working on translating this tutorial into Urdu, but it seems that no one has started the translation process for this article yet. If you can help us, then please click "More info".

Regular Expressions (Regex):

Introduction

We have previously talked a lot about strings - the ability to process and manipulate text is so important for all programmers out there! But while chopping up strings with the SubString method or doing some simple string-to-string replace operations can be considered simple string processing, string processing with Regular Expressions (usually shortened to Regex) is the extreme version!

First of all, Regular Expressions is not a Microsoft/.NET invention. In fact, Regular Expressions were invented way before the .NET framework, as a way of expressing a search pattern. This search pattern can then be used to carry out search or search-replace operations on a piece of text. Your first thought might be that you don't need another "language" to search through a string, but just wait and see what you can do with Regular Expressions!

The cool thing about Regular Expressions is that they are supported by pretty much every programming language out there, and while there are small variations, you can use the same regex across these programming languages to accomplish the same thing. The .NET framework has a very nice implementation of Regular Expressions, centered around the Regex class found in the System.Text.RegularExpressions namespace.

Summary

With Regular Expressions you can define a search pattern to perform search and search/replace operations on a string. The .NET framework can easily work with your Regular Expressions, as we will discover in the next articles, where we will work with the Regex class as well as helper classes like the Match and MatchCollection classes.


This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!