The Regex (Regular Expression) pattern empowers us to integrate validation into your text field, providing control over the data input. This validation feature serves as a mechanism to limit the characters entered into your text box. For example, we can set parameters that restrict the user to input only characters from A to H, or confine the input exclusively to lowercase characters, among other possible constraints.
Presets and Validator
To utilize the pattern feature, start by creating a text field. You'll find a dropdown menu under the option Pattern offering a selection of popular pre-set regex patterns to choose from. If these presets don't align with your requirements, you have the option to input your own custom regex. Highlighted below there's a button that opens additional options for pattern modification, granting you further flexibility to tailor the pattern as per your needs.
You'll then be directed to a screen that provides the same number of preset options as before, but this time, the regex box gets populated automatically. You can either edit this pre-filled regex pattern with extra validation rules or forgo the preset and craft a regex expression from scratch. To ensure the efficacy of the validation without publishing, a 'Test' option is available. This feature allows you to verify whether the input you've entered aligns with the defined validation rules.
Some Common Examples:
Alphanumeric without Spaces
/^[a-zA-Z0-9]*$/
Whole Numbers
/^\d+$/
UpperCase Letters with white space
[A-Z\s]+
LowerCase Letters with white space
[a-z\s]+
Colour HexCode
Colour Hexcode "^#(?:[0-9a-fA-F]{3}){1,2}$
Allow only the characters A-Z, A-z, 0-9, \/_,;'|$£&+()@-.
[^a-z^A-Z^0-9\^_^/^\\^,^:^;^|^$^£^&^+^(^)^@^-^.]
For a more detailed explanation of Regex a suggested article is:
https://www.regular-expressions.info/quickstart.html
A useful resource to help test regex expressions
https://www.regextester.com/95926
Use Case Examples
Match Any Email Address from a Specific Domain | |
Usage Example | Match any email address from the domains hotmail.com, and gmail.com. |
Regex | (\W|^)[\w.\-]{0,25}@(hotmail|gmail)\.com(\W|$) |
Notes |
|
Match Word or Phrase |
|
Usage Example | Match any word or phrase in the following list:
|
Regex | (?i)(\W|^)(Softools|Gridfields|Zero\sCode)(\W|$) |
Notes |
|
Comments
0 comments
Please sign in to leave a comment.