Follow

Regular Expressions

You use regular expressions when creating custom fields. Here is a list of available options.

 Characters

 Use  To match  NOT
 [set]  Any character in that set  [^set]
 [a-z]  Any character in the range a - z  [^a-z]
 .  Any character, except newline  
 \w  Word character  \W
 \d  Decimal character  \D
\s  White space  \S
\char  Escaped special character  

 

Quantifiers, Anchors and Alternation

 Quantifiers

 To match
 *  0 or more times
 +  1 or more times
 ?  0 or 1 time
{n} Exactly n times
{n,m} From n to m times

Anchors

To match
^ At the start of the string
\A At the start of the string
\z At the end of the string
$ At the end of the string
\G Where the previous match ended
\b On the word boundary
\B Not on the word boundary

Alternation

To match
a|b a or b
(?{[exp, name]} yes | no) Yes if the expression or name is matches, else no

Examples

 ^\d+$ Integers only
^\w+$ Alphanumeric characters
^\$?\d+$ US Dollars
^\£?\d+$ UK Pounds
^((((0[13578])|([13578])|(1[02]))[\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\/](([1-9])|([0-2][0-9]))))[\/]\d{4}$|^\d{4}$ US Date
^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$ UK Date, including leap year calculation

 

Worked example

To explain a little more, if we break down the US date example like this:

^((((0[13578])|([13578])|(1[02]))

 If from the beginning ("^") the number is 01, 03, 05, 07, 08, 1, 3, 5, 7, 8, 10, 12 (or January, March, May, July, August, October December)

[\/]  After the backslash
(([1-9])|([0-2][0-9])|(3[01])))|  You can have any number between 1 and 31
(((0[469])|([469])|(11))  If the month is April, June, September or November
[\/]  After the backslash
(([1-9])|([0-2][0-9])|(30)))|  You can have any number between 1 and 30
((2|02)  If the month is February
[\/]  After the backslash
(([1-9])|([0-2][0-9]))))  You can have any number between 1 and 29
[\/]  After the backslash
\d{4}$|^\d{4}$  You have the year
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk