How to express "OR" in variable conditions

I want to say in variable condition
if the variable X is 1 or 2 or 5 then do blah..

how do I express the "OR" just comas ? doesn't seem to work...

Thx

Use matches and the bar glyph (⇧\).

1 Like

Keep in mind that "matches" is different from "equals" or "is". For example, the conditional in the picture will be executed if Local_Test is 13 or 67.5 or 20003.

That's an excellent point that I should have been explicit about. My bad.

This is a safer option:

I think you could also use your original method, but explicitly as a regex with start and end markers:

2 Likes

Regex is not my forté so this is handy to know. :+1:t3:

Does that work with any string or just single numbers? I feel a favourite being saved... :crystal_ball:

AFAIK the "pipe for OR" construct is an implicit regex in KM, ie your 1|2|5 is actually .*(1|2|5).* -- "any one of this group of things, anywhere in the string". All mine does is say "the string must start (^) and end ($) with one of these three things, with nothing else there".

Looking for exactly "dog", "cat", or "fish"? Then ^(dog|cat|fish)$. Starts with those ("cats" but not "scat")? ^(dog|cat|fish) Ends with? (dog|cat|fish)$ And so on. KM infers .* -- 0 or more of (almost) any character when you don't use ^ or $.

2 Likes