<< Click to Display Table of Contents >> Regular expressions |
A regular expression is a definition of a valid pattern of characters that can be inputted in a text box (i.e a given format).
This functionality is not meant to replace any inputted text nor to place a mask for it; it simply creates an automatic validation that will not allow the user to continue if the inputted text does not satisfy that given pattern.
It is useful to include regular expressions to optimize your user interfaces so that you avoid submitting erroneous information to Bizagi (the server) and avoid typos or having to process (and re-process) information.
For example, regular expressions can help you validate: specific VAT identification numbers of countries, telephone numbers, a valid URL, or specific product codes of your business.
A brief introduction on regular expressions and the most commonly used ones is provided below.
Explanation
As mentioned, the definition of a regular expression considers a valid range of characters and pattern. Optionally it can specify, any number of valid occurrences of those characters/patterns.
The syntax to define that only numbers are allowed is set as (having ^ indicate the beginning and having $ indicate the ending of the text):
^[0-9]*$
If instead of allowing any number or recurrences of number, you wish to allow exactly 3, you would use:
^[0-9]{3}$
Similarly, to define that only letters are allowed this syntax is used:
^[a-zA-Z]*$
Notice that the above specifies upper and lower case letters. Only upper case letters is specified as:
^[A-Z]*$
You may include additional letters outside of the standard occidental alphabet, such as the Ñ letter used in Spanish:
^[a-zA-ZñÑ]*$
Allowing blank spaces is specified by using \s:
^[a-zA-Z\s]*$
Common examples
Bizagi already includes pre-defined validations for the most common string-based patterns such as a valid E-mail address validation.
For more information about the E-mail address validation, refer to Actions and validations.
Additional and specific validations would be set in this property. You may refer to the examples presented in the table below:
REGULAR EXPRESSION |
WHAT INFORMATION IT ALLOWS |
---|---|
((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?) |
A valid URL (includes mailto:, a URL having query parameters, using HTTPS, etc) |
^0[1-6]{1}(([0-9]{2}){4})|((\s[0-9]{2}){4})|((-[0-9]{2}){4})$ |
A telephone number format for a specific country; in this case just as it is valid in France |
^([GB])*(([1-9]\d{8})|([1-9]\d{11}))$ |
A valid VAT number for the UK |
^\d{10}$ |
A 10-digit number |
[0-9]{3}-[0-9]{2}-[0-9]{4} |
A ###-##-#### social security number as used in the U.S.A |
^([0-9]{5}-[0-9]{4})$ |
A 9-digit zip code, as used in the U.S.A. |
Last Updated 1/6/2022 11:28:12 AM