Regular expressions

A regular expression is sort of a template that prescribes how the contents of a field should be formatted. You can use it to indicate what characters Collections should accept in the input and what characters should appear at what position.
In Collections, regular expressions can be set in the properties of entry fields on screens and in field and screen conditions, to limit user input for those fields.

The following format codes are available:

Character(s)

Meaning

.

Any character may be entered by the user at the position of this character in the regular expression. For example: .... means that the user may enter four random characters.

*

The preceding character or expression may occur zero or more times. For example: [0-9]* indicates that any number from 0 through 9 may occur zero or more times at the position of * in the regular expression.

Note that some special regular expression syntax applies in field and screen conditions, also relating to the use of an asterisk.

+

The preceding character or expression must occur at least once but may also occur more times. For example: [b-f]+ indicates that any letter from b through f may occur one or more times at the position of + in the regular expression.

?

The preceding character may occur 0 or 1 times at the position of ? in the regular expression. For example: !? means that ! may occur here once, or not at all.

[characters]

Insert all the characters that are allowable for input by the user at this position in the regular expression, between the brackets, without spaces in between the characters, for example: [aHgm].

[x-y]

The allowed input of one character falls within the range x - y, for instance [a-z] or [0-9].
More than one range can also be provided, by placing them directly behind each other between the brackets, for example: [0-9a-z].

[^characters]

Insert all the characters or a range between the brackets and after the '^' symbol that may not occur at this position. For example: [^0-9] which means that the numbers 0 through 9 may not occur at this position.

^

Only when this character is inserted at the very beginning of a regular expression, it means that input should start with the expression or characters following this character.

$

This character indicates the end of the allowable input. No more characters may be entered by the user.

\character

The character that may occur at this position is a special character reserved for use in a regular expression. An example is the full stop, which is used in regular expressions as a wildcard. If you want the user to be able to enter a full stop as a character, place it behind a backslash: \.
Another example is \?|\*|\^ which means that the user may either enter a ?, a * or a ^.

expression 1|expression 2

Allowed input either matches expression1 or expression2. The symbol for OR is a vertical line. For example: ^[0-9]$|^x$ means that the user may enter either a number or an x.

 

Below you'll find some more examples of how to use regular expressions in the Regular expression property of an entry field on screen:

Character(s)

Allowed input

h..se

an h followed by any two characters, followed by se. This would match horse and house, for example.

The.*house

the text The followed by any one or more characters, followed by house. This would match: The house, The new house, The boathouse, but not Thehouse.

[Ee]xample

the word example, spelt with either a capital or a lower case e.

l[aeiou]nger

a word with a vowel at the second position. For example: longer, linger, etc.

[1-9][0-9][0-9][0-9] [A-Z][A-Z]

the regular expression for Dutch post codes. Allowed values are: 1234HK or 9000ZA, but not 0434AB or 3456hj.

^book$|^serial$

the word book or the word serial.

^[a-z]*$|^[0-9]*$

a random length string of lower case letters or a random length string of digits

See https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference for more information about regular expressions used by Axiell Collections and http://www.cplusplus.com/reference/regex/ECMAScript/ for more information about regular expressions used by Adlib for Windows. Since the ECMAScript regular expression syntax is a subset of the .NET flavour, regular expressions made for Adlib will also work in Collections. Note that there are other websites which can validate any string to your regular expression, to help you find out if your regular expression is correct: https://regex101.com/ for ECMAscript syntax for example.