What are regular expressions (Regex) and how do they work?
The use of regular expressions throughout the platform is supported in dynamic values of form fields and screen properties using the following formulas, where applicable.
- REGEX(input, pattern)
Returns true/false based on whether the regular expressions pattern finds a match in the input string. - REPLACE(input, patter, replacement)
Replaces the text matched by the regular expression pattern with the text specific in the replacement string.
Examples:
Removing duplicates from a pipe-separated list
Let's say you have a string with multiple values pipe-separated that contain duplicates, and you'd like to remove all duplicates to only display unique values in the list. The following regex can help with that.
What you'll need is a string input with pipe-separated values and, for example, a text field's dynamic value property with the regex REPLACE() function containing the input list and regex pattern.
Input
1|2|2|3|3|3
Regex Formula
REPLACE({{input}}, '(?<=\||^)([^\|]+)(?=(?>\|[^\|]*)*\|\1(?>\||$))\|', '')
or
REPLACE({{input}}, '\b(\w+)\|(?=.*\b\1\|?)', '')
Output
1|2|3
Form Designer
What you will see In-app