1. Home
  2. Other Resources
  3. Tips & Tricks
  4. Regular Expressions in Filters

Regular Expressions in Filters

regular expressions used in filter condition

Regular expressions, also called RegEx, are a description of a sequence of characters that define a search pattern. A more detailed explanation, including a description of the syntax, can be found here: https://en.wikipedia.org/wiki/Regular_expression

NOTE: Regular Expressions can only be used on input fields with the datatype “string”. This means no direct validation can be applied to the input field.

On this page we will show some frequently used regular expressions. They can be used for validations and filters.

IBAN

Multi-national
Example: ES7921000813610123456789

^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$  

Germany (with or without spaces)
Example: DE89 3704 0044 0532 0130 00 or DE89370400440532013000

^DE\d{2}[ ]\d{4}[ ]\d{4}[ ]\d{4}[ ]\d{4}[ ]\d{2}|DE\d{20}$  

Switzerland (with or without spaces)
Example: CH93 0076 2011 6238 5295 7 or CH9300762011623852957 or CH9300SURVALYZER0000X

^CH\d{2}[ ][A-Z0-9]{4}[ ][A-Z0-9]{4}[ ][A-Z0-9]{4}[ ][A-Z0-9]{4}[ ][A-Z0-9]{1}|CH\d{2}[A-Z0-9]{17}$

Netherlands
Example: NL91ABNA0417164300

^NL\d{2}[A-Z]{4}0\d{9}$  

Email

This is the standard regular expression using the RFC 5322 Official Standard:
Example: john.doe@survalyzer.com

^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$

Phone Numbers

Germany
Allows several formats:
Examples: 004989123456, +49 89 123456, +49(89)123456, 089-1234-5678, 089 1234 5678, (089)1234-5678

^(((((((00|\+)49[ \-/]?)|0)[1-9][0-9]{1,4})[\-/]?)|((((00|\+)49\()|\(0)[1-9][0-9]{1,4}\)[ \-/]?))[0-9]{1,7}([\-/]?[0-9]{1,5})?)$ 

Switzerland
Allows several formats:
Examples: 044 276 47 44, +41442764744, 00412764744, +41 44 276 47 44

^(0|0041|\+41)?[1-9\s][0-9\s]{1,12}$

Netherlands
Allows several formats:
Examples: 0612345678, +31612345678, 0031612345678, +31(0)61 234 5678

^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9])((\s|\s?-\s?)?[0-9])((\s|\s?-\s?)?[0-9])\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]$

Generic
Allows several formats:
Examples: 089 123 4567/8, 0041-44-276-4744, +31.61.234.5678

^(0|00|\+)[1-9][0-9\s\-\/.]{1,}[0-9]$

ZIP Codes

Germany:
Example: 24143

/^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$/ 

Switzerland:
Example: 5033

^([1-468][0-9]|[57][0-7]|9[0-6])[0-9]{2}$ 

Netherlands:
Example: 1000AB

^[1-9][0-9]{3}\s*[A-Za-z]{2}$

Updated on October 22, 2021

Was this article helpful?

Related Articles