Loading...
 

Regular expressions

Regular expression (or regexp for short) is a special text string for describing a search pattern. You can get more information about basic syntax for setting regular expressions at http://www.regular-expressions.info/reference.html.

Examples of regular expressions:

  • [abc] matches a, b or c
  • [a-zA-Z0-9] matches any letter or digit;
  • [^a-d] matches any character except a, b, c or d
  • a{3} matches aaa
  • regular expression for ip address:
     \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.
    (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b 
    matches 1.2.3.4
  • regular expression for email address:
     ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ 
    matches contact at abc.com

To get more information about setting regular expression as validation, check Validations.