Regular Expression

The Regular Expression validation checks the contents of a specified server variable to determine if its value conforms to a format specified in a regular expression. Several existing regular expressions are available to choose from, or you can specify a custom regular expression. It can also be configured to accept blank entries.

Note: As a resource, we have provided several sample regular expression strings at teh end of this document that can be used in conjunction with this behavior.



Set the configuration options and click OK to complete configuration of the validation within the Server Validation dialog.

The following options are available for configuration of the Regular Expression validation:
  • Expression: Enter the regular expression that provides the comparison for the validation.
  • Allow blank entry: configures the validation to allow blank entries or not allow them.

Sample Regular Expressions

Type Description Regular Expression
Currency - US Works with or without commas and/or dollar sign. Decimals are not mandatory, unless there is no zero in the ones column and a decimal point is placed. Allows $0.00 and .0, but not leading zeros in any other cases. /^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/
Credit Card Matches major credit cards including: Visa (length 16, prefix 4), Mastercard (length 16, prefix 51-55), Discover (length 16, prefix 6011), American Express (length 15, prefix 34 or 37). All 16 digit formats accept optional hyphens (-) between each group of four digits. /^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$/
Date/Time - US This expression validates dates in the US m/d/y format from 1/1/1600 - 12/31/9999. The days are validated for the given month and year. Leap years are validated for all 4 digits years from 1600-9999, and all 2 digits years except 00 since it could be any century (1900, 2000, 2100). Days and months must be 1 or 2 digits and may have leading zeros. Years must be 2 or 4 digit years. 4 digit years must be between 1600 and 9999. Date separator may be a slash (/), dash (-), or period (.). /^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/
Email Email validator that adheres directly to the specification for email address naming. It allows for everything from IP address and country-code domains, to very rare characters in the username. /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
Fractions This expression is used to validate fractions (entered as strings). It will also accept non-fractional entries. /^\d* \d*\/{1}\d*$|^\d*$/
Number This matches any real number, with optional decimal point and numbers after the decimal, and optional positive (+) or negative (-) designation. /^[-+]?\d+(\.\d+)?$/
Number - Scientific This matches floating point expressions - accepts both exponent as well as non exponent notations. /^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?$/
Password Matches a 6-8 character password that has to consist of numbers and letters with at least one letter in it. /^(?![0-9]{6,8})[0-9a-zA-Z]{6,8}$/
Phone - US This is a basic US phone number verification. It allows +/- signs, digits, spaces and blank entry. /(^(\+?\-? *[0-9]+)([,0-9 ]*)([0-9 ])*$)|(^ *$)/
Phone - International Allows for an international dialing code at the start and hyphenation and spaces that are sometimes entered for international phone numbers. /^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/
Post Codes - UK Matches UK postcodes according to the following rules:
1. LN NLL (eg. N1 1AA)
2. LLN NLL (eg. SW4 0QL)
3. LNN NLL (eg. M23 4PJ)
4. LLNN NLL (eg. WS14 0JT)
5. LLNL NLL (eg. SW1N 4TB)
6. LNL NLL (eg. W1C 8LQ).
/^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$/
URL Matches ftp, http, https without any trailing information. Matches TLD's and Country Codes from 2-4 letters, port numbers, and username:password@ for authentication. Also matches IP addresses http://0.0.0.0 - http://255.255.255.255 /^(http|https|ftp)\:\/\/((([a-z_0-9\-]+)+(([\:]?)+([a-z_0-9\-]+))?)(\@+)?)?(((((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))))|((([a-z0-9\-])+\.)+([a-z]{2}\.[a-z]{2}|[a-z]{2,4})))(([\:])(([1-9]{1}[0-9]{1,3})|([1-5]{1}[0-9]{2,4})|(6[0-5]{2}[0-3][0-6])))?$/