How the Regular Expressions are used?

In this article , we will explore about Regular Expressions , few basic concepts about it. Mainly for validation purpose , regex or regular expressions are used. I hope this article will be useful for you.

Regular expressions


Regular expressions are used when user needs to search combinations of charaters from string.
Specific criteria has to be given by end user in which searching can be done.
It increases effeciency and get results faster.
Different validations can also be implemented by using regular expressions.
For eg. To validate email id of the user.
or to validate any phone number , datetime etc .
The System.Text.RegularExpressions.Regex class can be used to search strings.
Regular expressions gives flexible way for searching strings which are seperated by any delimiter or space.
Parentheses are used to define the scope.
A backslash escapes special characters to suppress their special meaning.
Caret i.e. ^ negates the character class.
[\b] here \b is a backspace character if it is inside a character class.
If you know the significance of each of characters in regex pattern , you can make your own complex custom validations by using regex.
We can include hiphen , digits , alphabets and its different combinations.
Regular expressions also supported by PERL , JAVA , Javascript.
IsMatch: A Boolean value is returned depending on whether the pattern is matched in the string or not.

Regex pattern_for_other_than_numbers = new Regex("[^0-9]");

This expression returns true for values which do not come under 0-9.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: