Regular Expressions Overview

   MaestroPreviously known as Transact Maestro.  |   Form Builder |  v5.1 & Higher This feature is related to v5.1 and higher.

Regular expression validation rules are patterns used to match character combinations in strings. They are special text string for describing a search pattern. They are like wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is ^.*\.txt$.

But you can do much more with regular expressions. You could create the regular expression \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b to search for any email address. A very similar regular expression (replace the first \b with ^ and the last one with $) can be used to check whether the user entered a properly formatted email address. Regular expressions are very compact, so it can be written in just one line of code.

In JavaScript, regular expressions are also objects. These patterns are used with the exec and test methods of RegExp, and with the match, replace, search, and split methods of String.

Below are several patters that can be handy to use:

  • an email address validation - ^[a-zA-Z0-9_-\.]+@[a-zA-Z0-9_-\.]+\.[a-zA-Z]{2,4}$
  • an URL validation - ^http\://[a-zA-Z0-9-\.]+\.[a-zA-Z]{2,3}(/\S*)?$

For more information, see the following resources: