• Futurama Formulas - Date and time
• Futurama Formulas - Math
• Futurama Formulas - Statistical
• Futurama Formulas - Text
• Futurama Formulas - Logical
• Futurama Formulas - Table
• Futurama Formulas - Document
• Futurama Formulas - Conversion
• Futurama Formulas - Matrix
• Creating custom formulas in Futurama

Module: Editor

Version: 2.2.1 +

Type: Boolean

Category: Text

## Description

The formula ‘ ValidatePattern’ returns 'True' if a text string matches a specified regular expression. With a regular expression you can describe the format of a text string without describing the entire expression. You use this formula for example to validate if the input of an user of your website matches the format that you expect for this input. For example when you expect the user to fill in a double to give his salary, you can use the formula 'ValidatePattern' to check if a double is filled. Otherwise you can give a error feedback to the user. See the external links section of this page to find more information abouw regular expressions.

## Parameters

Text:

This is the text that has to be validated for his pattern

Pattern:

This is the regular expression that is used in the validation of the parameter 'Text'

To describe the pattern the next regular expression syntax is important:

• A dot (.) stands for any symbol
• With square parentheses you can give a list of possible symbols. For example [adf]
• The minus inside the square parentheses gives a serie of symbols. For example [a-z] for all the lower case letters, [a-zA-Z] for as well the lower as the upper case letters
• If the caret is the first symbol in the square parentheses, it will accept everything but the symbols behind the caret. As example: [^0-9] accept everything but the numbers 0 till 9 or [^a-z] accept everything but the letters a till z.
• A caret (^) stand for the start of a regular expression.
• A dollar sign (\$) stand for the end of a regular expression.

The syntax above here can be combined with the constructions mentioned below:

• A vertical bar separates alternatives, as example "green|red" recognizes "green" and "red".
• A plus (+) indicates that the previous text must appear at least once.
• A question mark (?) indicates that the previous text cannot appear more than once.
• An asterisk (*) indicates that the previous text may appear, but not strictly have to.
• A {m} indicates that the previous text must appear exactly  'm' times.
• A {m,n} indicates that the previous text must appear at least 'm' times but not more then 'n' times. If there is no 'n' it indicates that the previous text has to appear at least 'm' times.
• The best way to explain the construction (?=...) is by using an example. As example 'Football(?=supporters)', this construction means that the symbol 'supporters' has to be right behind the symbol 'Football', so 'Footballsupporters'. This construction will accept 'Footballsupportersclub' but it will not accept 'Footballsupporterclub'.
• The reversed construction of (?=...) is (?!...). As example "Football(?!supporters)", this construction means that it will accept every symbol right behind 'Football' except the symbol 'supporters'. So this means that 'Footballsupporterclub' will be accepted and 'Footballsupportersclub' not be accepted.
To describe a number you can use the expression [0-9] or you can use the short notation \d. The short notation to describe everything but a number is \D.

## Example

### Description

Below here you will see 2 examples:
1. The pattern is a{3,5}b, this means that the text 'aaab' matches this pattern and the text 'aaaaaab' doesn't match pattern.
2. The pattern is (test){1,2}. The text 'test' matches the pattern and the text 'testtest' also matches this pattern.

## Examples of frequently used regular expressions

### Zip Code

##### Description

A Dutch Zip Code is displayed by a series of 4 numbers and 2 letters. These letters and numbers are separated by a space. The first letter of a Dutch Zip Code has to be a number between 1 and 9. These requirements are translated in the regular expression mentioned below.

##### Regular Expression

^[1-9]{1}\d{3}[]?[a-z|A-Z]{2}\$

### Date

##### Description

There are many ways to describe the format of a date. An example of a date format is using 2 numbers for the day, separation mark (-), 2 numbers for the month, separation mark (-) and 4 numbers for the year. This example can be translated in the next regular expression.

##### Regular Expression

^(\d{1,2})-(\d{1,2})-(\d{4})\$

### Amount according to the Dutch notation

##### Description

There are many ways to describe the format of an amount. According to the Dutch notation it is common that it is allowed to use 0, 1 or 2 decimals. For the decimal separator a comma (,) has to be used, and for the thousands separator a dot (.) has to be used. Theze requirements lead to the next regular expression.

##### Regular Expression

^(\d{1,3}\.?(\d{3}\.?)*\d{3}(,\d{1,2})?|\d{1,3}(,\d{1,2})?)\$

### Amount according to the English notation

##### Description

There are many ways to describe the format of an amount. According to the English notation it is common that it is allowed to use 0, 1 or 2 decimals. For the decimal separator a dot (.) has to be used, and for the thousands separator a comma (,) has to be used. Theze requirements lead to the next regular expression.

##### Regular Expression

^(\d{1,3},?(\d{3},?)*\d{3}(\.\d{1,2})?|\d{1,3}(\.\d{1,2})?)\$

### Percentage

##### Description

The expression has to describe a percentage between 0% and 100% with a maximum of 2 decimals. For the decimal separator you may use a dot (.) or a comma (,).

##### Regular Expression

^100\$|^\d{1,2}\$|^\d{1,2}[.,]{1}\d{1,2}\$

##### Description
For passwords is very common to use a regular expression. This means that the password must match certain requirements. As example, these requirements could be the amount of characters in the password and the different kind of symbols (uppercase, lowercase, numbers) in the password.
##### Regular Expression

Suppose a password has the next requirements:

1. A password must contain at least 10 characters;
2. A password must contain at least 1 lowercase;
3. A password must contain at least 1 uppercase;
4. A password must contain at least 1 number;
5. A password must contain at least 1 symbol out of the next collection {@,#,\$,%,^,&,+,=};
The expression is:
^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#\$%^&+=]).*\$