This article I will discuss about regular expression (or RegEx in short) class in .Net
Regular Expression is a big topic and cannot be covered in a single article. I tried to explain it in brief.
In dot net there is a strong support for regular expression class. A regular expression is a string that is used to describe match based on certain rule. Regular expression is a very powerful tool for pattern matching.
Regular Expression can be found in System.Text.RegularExpressions namespace.
Example for using regular expression:
if (Regex.IsMatch("ASP.Net", "ASP"))
{
MessageBox.Show("match");
}
else
{
MessageBox.Show("no match");
}
Above example ("where "ASP" is a pattern") search for the matching world "ASP" in the string "ASP.Net", if match found, shows message "match".
Similar way different pattern can be passed for searching a particular string.
Note: Regular Expression is a case sensitive; "a" is different from "A".
Example:
Join the conversation! Your thoughts help the community grow.