I am trying to use regex to match values in a switch statement, so I don’t have to create a separate case for similar values.
<switch xmlns:ns="http://org.apache.synapse/xsd" source="$ctx:val">
<case regex="5 | 2">
<log level="custom">
<property name="log1" value="hit"/>
</log>
</case>
</switch>
However, this doesn’t seem to work. It works if I create two separate cases for “5” and “2”. Any ideas? Thanks.
The spaces will be treated as literal characters in regex that are required for the match. Simply remove them: