Regular Expression to check a field for two values.

Hello There,

How can we check a filed for two values.

I am currently using this expression in the label of one of the sequence:


But, the above expression is not working…Any other thoughts please?


BRANCH on fieldName

In labels, the regex needs to start and end with /.



Hi Senthil,

The condition you suggested will work only if the ‘input’ value starts with either A or B. I was looking for a check that satisfies if the input value is either ‘A’ or ‘B’.



I was mistaken. The label can indeed be an expression as you’ve listed. I tested this with success:

(The … are just to show indentation)

BRANCH (evaluate labels set to True)
…%input%==/^A$|^B$/ || %input%==‘C’: SEQUENCE

All test variations perform as expected–only a stand-alone A, B or C matches.

[Edit] My personal preference is to avoid evaluate labels when possible. For your scenario, you could use:

BRANCH on ‘/input’
…/^A$|^B$|^C$/: SEQUENCE (do something when input is A, B or C
…D:SEQUENCE (do something else when input is D)
…$default: SEQUENCE (do something new in all other cases)

Hi Reamon,

The condition that you suggested before(/A|B/) does work for FieldName starts with A or B, but , i was looking for to check FieldName that has value of only A or B.

But, the condition that you posted in the latest thread (…%input%==/^A$|^B$/ || %input%==‘C’) works absolutely fine. For the scenario i’m looking for.

As you said, Evaluate labels should be avoided, but in my case it is required i guess. As i am validating two different fields (My Bad, That i have not mentioned correctly in my previous post), but you could observe the requireent by seeing the below screenshot.

In the below screenshot the first condition satisfies my requirement, but the second one doesn’t.

Thanks Reamon,

Just for clarification…

/A|B/ will match if A or B appears ANYWHERE within the variable value. Thus, it would match on foobAr, fooBar, Fozzy Bear, Barney Rubble, Kyle Broflovski, Jennifer Aniston, etc.

/^A|^B/ will match any value that starts with A or B.

^ - indicates the start of the string
$ - indicates the end of the string

Guys… got a doubt… If you just have only 2 values to be compared absolutely, why should you look for regular expression… Regex is specifically for matching the patterns of strings… Why not just use the generic logical operator that makes the comparison? Or am I missing something obvious in the use-case?



I was like curious to know this one. Moreover, In our code the path of the fields that we check were very long, so was looking for regular expression…

Thanks Senthil,

Hmm… I would do this to reduce the path of the field. Add a map step before the Branch, and map the values to temporary variables… These variables can be used in Branch which will give more readability…


One funny thing that happened his. I was struck with the same question again and i found my own post, which i realized it is me after a while of reading all the comments :). Anyways if we add $ symbol all the way in the end it of each word which will give us the expected outcome.

Attaching a screenshot.