In WebMethods, the most basic way to write a string “IN”
operator is to use Branch as follows:

Another way to reduce the number of lines of code is by combining
the conditions using “OR”:

These approaches works well if the number of options is
small or if the variable name is short. If there are more than a few options,
or in the case of a very long variable name, the code will look very messy, and thus, difficult to maintain. For example:
$work_order.maximo/ns:PublishZZWORKORDER/ns:ZZWORKORDERSet/ns:WORKORDER[0]/ns:STATUS/*body
 
Using regular expression can simplify the code:

To implement the string “IN” logic, we can use /^value$/.
For example, the code below would evaluate to true if $input is exactly one
or two or three

 

To implement the string “CONTAINS” logic, we can use /value/.
For example, the below would return true if $input string contains one:

With Regex, it is also simple to check if the variable
contains one of several values:

My favourite Martin Fowler’s quote isAny fool can
write code that a computer can understand
. Good programmers write code that humans can understand. This trick helps me to keep most of my code fits in
a single screen.

Happy coding.