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

 

    • Related Articles

    • Custom Validation

      Validating data at the point of entry can be vital when a value must be within a specific range, length, or format. This can inform users about the data required within fields and ensure accuracy. Formulas using functions from our Formula Cheat Sheet ...
    • Formula Cheat Sheet

      Below is a comprehensive list of Appenate’s formula functions that can be used in various field properties throughout the platform, wherever the hammer icon is present. CONTEXTUAL USEREMAIL() User’s Email Address. USERFIRSTNAME() User’s First Name. ...
    • Formula Cheat Sheet

      Below are a list of most of the platform formula builder functions that can be used in formulae. 1. CONTEXTUAL FORMULAS TODAY() Current Date The current local date reported by the device. NOTE: Device dates can be inaccurate if the local time is not ...
    • Device Language & Numeric Fields

      Depending on your region or device language set, the Numeric Field will capture decimal values separated by a point (.) or a comma (,). If the numeric field’s value is needed in calculations, you must ensure the separator is a point (.). This can be ...
    • Repeatable Data in Templates

      After capturing repeatable data, you might want to customize how it displays in a PDF output using Word or Excel templates. There are two ways to output the answers for these repeatable fields in your template: Repeat rows in a Word table or Excel ...