Conditional Logic Regex Matching
Regex matching is a way of comparing an answer to a pattern defined by a regular expression (regex). This topic describes how to set up a Conditional Logic If condition with the Match (regex) operator. It also lists the requirements and limitations that you need to know when you set up regex matching.
Tip:You can test your regex using online tools.
Available on the Enterprise tier only:
Contents
What is regex matching
Regex matching is a way to set up a Conditional Logic If statement to compare an answer to a pattern. For example, you can use a regular expression (regex) to set up matches for:
-
Case-sensitive text
-
Ends with
-
Starts with
-
Wildcard characters (single and multiple)
Set up regex matching
Prerequisites
-
You must be either:
-
A TrueContext Admin user.
-
A member of a FormSpace FormSpaces are where forms are stored and organized in the TrueContext Web Portal. A TrueContext Team may have multiple FormSpaces, depending on their needs. Admins can set FormSpace permissions to control which users have access to the forms in that FormSpace. group with Can Create permissions.
-
-
You must know how to build a regular expression.
-
Your field users must have the TrueContext Mobile App version 16.3 or later.
Steps to set up regex matching
Info:The topic Building Conditional Logic Rules: Create a Conditional Logic Rule describes in detail how to add and save a rule.
-
From the Forms & Integrations menu, create or edit a Mobile App form.
-
To create a new form:
Forms & Integrations > Create New Form > Build a Mobile Form
Enter a name and description, and then save the form.
-
To edit a form:
Forms & Integrations > List Forms > FormName > Edit Form
where FormName is the form that you want to edit.
-
-
At the top left, select Conditional Logic.
-
Select or create a rule, and then go to the If statement.
-
Select the reference question that you want to use in the condition.
The following table lists the supported question and data types for regex matching.
Question types Data types -
Barcode Scanner
-
Button Group (data value)
-
Card List (data value)
-
Dropdown (data value)
-
Radio Button (data value)
-
Slider
-
Stepper
-
String Concatenation
-
Text Area
-
Text Field
-
Free Text
-
Integer
-
Decimal
-
Currency (value only, not the currency symbol)
-
Email Address
-
Phone Number
-
URL
-
Barcode
-
-
Select an operator:
-
Matches matches (regex)
-
DoesNotMatch does not match (regex)
Note:The Form Builder prevents you from setting up regex matching on unsupported question and data types. If the list of available operators doesn’t include regex matching, check the question type that you selected.
-
-
Enter the regular expression. The following table provides some examples.
Description Regex Text string that has all lowercase letters [a-z] 32-character hexadecimal string [0-9a-f]{32} Specific number format:
-
The first digit is a number between 4 and 9.
-
The second digit is a number between 0 and 9.
-
The third digit is a number between 5 and 9.
-
The last six digits are numbers between 0 and 9.
Examples:
-
405654321
-
999123456
^([4-9][0-9][5-9][0-9]{6})$ Four to six digits, followed by an A ^(\d{4,6})(A)$ A digit between 2 and 9, or any number with at least 2 digits ^(?:[2-9]|\d\d\d*)$ A string that starts with ORD- ^ORD- A string that ends with BOX BOX$ A string that starts with ORD- and ends with BOX ^ORD-.*BOX$ A string that starts with ORD-, followed by 10 digits ^(ORD-[0-9]{10})$ Tip:You can test your regex using online tools.
-
-
To finish building the rule, complete the steps described in the topic Building Conditional Logic Rules: Create a Conditional Logic Rule.
Note: To make sure your Conditional Logic rules work as intended in the field, test them thoroughly before you deploy the form. Test the form under a variety of conditions to validate the field user experience.
Limitations of regex matching
-
On iOS and macOS, field users could get unexpected results if the regex checks for single or double quotes. This is due to Apple’s “Smart Punctuation” feature, which automatically converts straight quotation marks ("hello") into “smart” quotation marks (“hello”).
For example:
Regex Match Non-Match ^["'].*["']$ "joe" “joe” Field users can either:
-
Switch off Smart Punctuation in their Keyboard settings.
-
Long press the quotation mark keyboard button.
-
-
Different browsers might handle regex differently.
Note: To make sure your Conditional Logic rules work as intended in the field, test them thoroughly before you deploy the form. Test the form under a variety of conditions to validate the field user experience.