How to Write / Formulation Regex

Regex is a regular expression that defines or restricts what a user inputs/fill on the input questions (Input text, Integer, decimal, etc).  We have a provision to use it both in the list and in the workflows, see below on how to formulate one. 

  1. Characters definition;

  • [] - A set of characters

  •  \ - Signals a special sequence (can also be used to escape special characters)

  • . - Any character (except newline character)

  • - Starts with

  • - Ends with

  • {} - Exactly the specified number of occurrences

  • | - Either or - Used to easily combine regex with two or more functions

  • () - Capture and group

  1. Sets descriptions;

  • [0123] - Returns a match where any of the specified digits (0, 1, 2, or 3) are present

  • [0-9] - Returns a match for any digit between 0 and 9

  • [0-5][0-9] - Returns a match for any two-digit numbers from 00 and 59

 

Examples

  1. ^([1-9]|1[012])$ 

  • ^ -  Anchors the regex at the start of the string

  • [1-9] - Matches 1 to 9

  • | - Basically used when you want to combine two or more regex - alternation matches the previous match or the following match.

  • 1[012] - Matches 10, 11, or 12

  • $ - Anchors the regex at the end of the string.

  1. ^2[0-9]{10}$ - Allows 10 Digits starting with a 2. 

  1. ^[0]{1}[1-9]{1}[0-9]{8}$ - Values need to have alteast 10 digits starting with a 0

  2. ^237[0-9]{9}$ - Values need to have at least 12 digits starting with 237

The best site to use in formulating Regex and testing them is Regex101, Please do test these Regex first before implementing them on the workflows/list.