Regular Expressions with Conditional Logic in Fluent Forms

Regular expression is not a library nor is it a programming language. Instead, regular expression is a sequence of characters that specifies a search pattern in any given text (string).

Basic Examples of Regular Expressions

RegexMatches any string
gray|greycontains {gray, grey}
gr(a|e)ycontains {gray, grey}
[Bb]treef\*\*kcontains {Btreef**k, btreef**k}
\d{5}(-\d{4})?contains a United States zip code
1\d{10}contains an 11-digit string starting with a 1
^catbegins with “cat”
cat$ends with “cat”
^cat$is exactly “cat”
Hello\nworldcontains Hello followed by a newline followed by world
\dcontains {0,1,2,3,4,5,6,7,8,9}
\d+(\.\d\d)?contains a positive integer or a floating point number with exactly two characters after the decimal point.
[2-9]|[12]\d|3[0-6]contains an integer in the range 2..36 inclusive

Let’s try to add a Regular Expression with Conditional Logic in a Form to understand it better. See the below screenshot –

  • Create a new form or an existing form to include the Conditional Logic with Regular Expression.
  • Add the input fields (For example, Radio Buttons, Checkboxes, Multiple Choices, etc) which will dictate the conditional input fields. For demonstration purposes, we are using the Text Input field here.
  • Add the Conditional input fields that will respond to specific user actions.

  • Go to the Input Customization of the conditional input field.

  • Go to Advanced Options and choose Yes in the Conditional Logic option.
  • Define the Input fields that the conditional field would rely upon.
  • Define what logics are to be satisfied- equal/not equal, greater than/less than, contains, start with/ends with/Regex match. Here, we will choose the Regex match.
  • Define which input field will respond if the logic is satisfied.
  • Click on the Save Form when you will be done.

Lets’ have a look at the below screenshots of how this works –

  • This Regular Expression is ^cat, and we can see from our Example chart that any string that begins with the word “cat” will work.
  • It will not work if the string does not match the Regex Pattern.

Was this article helpful to you?

How can we help?

Please submit a support ticket if you have any question or pre-sale questions. Our Customer support engineers will answer your query as soon as possible

Open a support ticket