Shivprasad Koirala
.NET interview questions :- What are Regex / regular expressions ?
By Shivprasad Koirala in ASP.NET on Mar 24 2011
  • Shivprasad Koirala
    Mar, 2011 24

    Answer:

    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.

    MessageBox.Show(obj.IsMatch(“shivkoirala”).ToString());
    

    Regards,
    View our 21 important .NET interview questions and answers from .NET Interview questions

     

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS