Regular Expressions
A regular expression is a sequence of characters that specifies a search pattern for a string that can be used for string validation. By providing a pattern you can flexibly specify rules for the string input field.
Language
We use ECMAScript specification for regular expressions parsing. Here is the table containing references for common tokens that can be used to construct a custom regular expression.
No |
Regular Expression |
Description |
1 |
. |
Matches any character |
2 |
^regex |
Finds regex that must match at the beginning of the line. |
3 |
regex$ |
Finds regex that must match at the end of the line. |
4 |
[abc] |
Set definition, can match the letter a or b or c. |
5 |
[abc][vz] |
Set definition, can match a or b or c followed by either v or z. |
6 |
[^abc] |
When a caret appears as the first character inside square brackets, it negates the pattern. This can match any character except a or b or c. |
7 |
[a-d1-7] |
Ranges: matches a letter between a and d and figures from 1 to 7. |
8 |
X|Z |
Finds X or Z. |
9 |
XZ |
Finds X directly followed by Z. |
10 |
$ |
Checks if a line end follows. |
11 |
\d |
Any digit, short for [0-9] |
12 |
\D |
A non-digit, short for [^0-9] |
13 |
\s |
A whitespace character, short for [ \t\n\x0b\r\f] |
14 |
\S |
A non-whitespace character, short for [^\s] |
15 |
\w |
A word character, short for [a-zA-Z_0-9] |
16 |
\W |
A non-word character [^\w] |
17 |
\S+ |
Several non-whitespace characters |
18 |
\b |
Matches a word boundary where a word character is [a-zA-Z0-9_]. |
|
||
19 |
* |
Occurs zero or more times, is short for {0,} |
20 |
+ |
Occurs one or more times, is short for {1,} |
21 |
? |
Occurs no or one times, ? is short for {0,1}. |
22 |
{X} |
Occurs X number of times, {} describes the order of the preceding liberal |
23 |
{X,Y} |
Occurs between X and Y times, |
24 |
*? |
? after a quantifier makes it a reluctant quantifier. It tries to find the smallest match. |
To validate and test your regular expression you can use regex101. Regex101 has every tool that can help you construct regular expressions. In addition to testing functionality, it has a full description of existing tokens for the most popular regular expression dialects.
NOTE: to ensure compatibility with the String Attribute regular expression feature you should select the ECMAScript (JavaScript) option in the FLAVOR menu in the right section of the page.
Presets
Presets allow you to quickly set up string field restrictions without diving into regular expression documentation. Custom Attributes support the following regular expression presets:
- Letters
- Letters and Numbers
- Letters, Numbers and Symbols
Letters
A regular expression that allows users to enter only letters.
Configurable parameters:
- Min Length: sets the minimum length of the string;
- Max Length: sets the maximum length of the string;
- Allow Spaces.
Resulting pattern examples:
- Example 1:
- Min Length: not provided
- Max Length: not provided
- Allow Spaces: true
- Resulting pattern: ([A-Za-z]|\s|\s)*
- Example 2:
- Min Length: 2
- Max Length: 5
- Allow Spaces: false
- Resulting pattern: ([A-Za-z]){2,5}
- Example 3:
- Min Length: not provided
- Max Length: 5
- Allow Spaces: false
- Resulting pattern: ([A-Za-z]){0,5}
Letters and Numbers
A regular expression that allows users to enter only letters and numbers.
Configurable parameters:
- Min Length: sets the minimum length of the string;
- Max Length: sets the maximum length of the string;
- Allow Spaces.
Resulting pattern examples:
- Example 1:
- Min Length: not provided
- Max Length: not provided
- Allow Spaces: true
- Resulting pattern: (\w|\s|\s)*
- Example 2:
- Min Length: 2
- Max Length: 5
- Allow Spaces: false
- Resulting pattern: (\w){2,5}
- Example 3:
- Min Length: not provided
- Max Length: 5
- Allow Spaces: false
- Resulting pattern: (\w){0,5}
Letters, Numbers and Symbols
A regular expression that allows users to enter any symbol.
Configurable parameters:
- Min Length: sets the minimum length of the string;
- Max Length: sets the maximum length of the string;
- Allow Spaces.
Resulting pattern examples:
- Example 1:
- Min Length: not provided
- Max Length: not provided
- Allow Spaces: true
- Resulting pattern: (\S|\s|\s)*
- Example 2:
- Min Length: 2
- Max Length: 5
- Allow Spaces: false
- Resulting pattern: (\S){2,5}
- Example 3:
- Min Length: not provided
- Max Length: 5
- Allow Spaces: false
- Resulting pattern: (\S){0,5}
A regular expression for email validation.
Resulting pattern: (\S+@\S\.\S+)*
Comments
0 comments
Please sign in to leave a comment.