Regular Expressions Examples (Regex)

Regular Expressions Examples (Regex)

What are regular expressions and how 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 expression pattern finds a match in the input string.

  • REPLACE(input, pattern, replacement)
    Replaces the text matched by the regular expression pattern with the text specified 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.

You’ll need 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+)|(?=.*b1|?)
', '')

Output

1|2|3

Form Designer

In-app