.NET interview questions :- What are Regex / regular expressions ?

 Posted by articlesmaint on 3/24/2011 | Category: .NET Framework Interview questions | Views: 2666

Regex or regular expression helps us describe complex patterns in texts. Once you have described these patterns you can use them to do searching, replacing, extracting and modifying text data.

Below is a simple sample of regex. The first step is to import the namespace for regular expressions.

using System.Text.RegularExpressions;


The next thing is to create the regex object with the pattern. The below pattern specifies to search for alphabets between a-z with 10 length.

Regex obj = new Regex(“[a-z]{10}”);


Finally search the pattern over the data to see if there are matches. In case the pattern is matching the ‘IsMatch’ will return true.



Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response