USe of regular expressions in branch condition

Hi all,

I’m trying to use regular expressions as given below in a branch condition with evaluate labels as true.

  1. /IDOC[0]/SEGMENT1/SUBSEGMENT1/NAME%==/[^TEMP|TEMP$|^TEST|TEST$]/ (same sequence of steps for both values starting or ending with TEMP and starting or ending with TEST )

  2. /IDOC[0]/SEGMENT1/SUBSEGMENT1/NAME%==/[value|VALUE]/ (didn’t work)

Neither of these work, I have to give each value separate like below:

/IDOC[0]/SEGMENT1/SUBSEGMENT1/NAME%==“VALUE” OR /IDOC[0]/SEGMENT1/SUBSEGMENT1/NAME%==“value” (Note that || didn’t work , I have to use OR)

But if I have to give like above for point 1, I would have to use the same sequence of steps again and again. Actually for point 1, I have to check for 2 more values with OR.

The incoming doc is an IDoc. Even in the case of XML input, using /[value|VALUE]/ works in one service but fails in the other.

This appears strange, please provide your suggestions on this.

Hi Venkata,

can you try to put the field in the switch property of the branch and place just the regex in the label?
Set “Evaluate Labels” to false.


Tried that too, not working.

Tried options like /[^VALUE|VALUE$]/ in label and VALUE|value, neither of them work.

I have used a similar regex in a sequence for an XML document, /[^<?xml version="1.0" encoding="UTF-8"?>]/ this works perfectly.
Is this something to do with the IDoc?

Hi Venkat,

you are using the wrong one /[^VALUE|VALUE$]/,make it this way-/(value)|(VALUE)/ or /^value|VALUE$/


hope this helps

He is right, you will want to use :


starts with VALUE or ends with VALUE

if you want to check if it contains the string VALUE, just go with


you might want to use /(?i)(VALUE)/ to ignore the case



1 Like

I tried /(<?xml version="1.0" encoding="UTF-8"?>)/, didn’t work. I will try the other conditions too and update.

Well if you want to match the whole xml header, you will have to escape the regex characters in it (backslash)

if you just want to verify if it matches any xml header this should do it :
%xmlString%=/<?xml .*?>/

Thank you for your suggestions. What would be the syntax to check for multiple values for a single variable? For eg. %/doc/field%==“value1”||“value2” (can be same operations for both values) and another sequence with %/doc/field%==“value3”||“value4” (different operations for value 3 & value 4) and a default and a null condition to check for.
Above syntax doesn’t seem to work. Question here is to avoid repeating steps for values mentioned with OR, particularly in cases where there are more values to be mentioned with OR.

branch on switch
and give the values to be identified as below,

/value1|value2|value3/ use in this way it works.For better understanding of regular exp use service development help

I am attempting to transfer files to different locations using the Branch switch sequence. The location would be determined based on the ending of the filename. like filename_A.ext will transfer to location A, filename_B.ext will transfer to location B, etc. What expression could help achieve the same?

like I have tried to use %remotefile% == /[^_A.ext]/, %remotefile% == /[^_B.ext]/ . But each time it will enter the same sequence.


did you check the “Evaluate Labels” Option?

As a variant you can use remotefile as the switch variable and specify the labels as “/[^_A.ext]/” and “/[^_B.ext]/”.


Hello Holger

I tried using the condition %remoteFile% == /[^_A.ext]/ into the sequence label. Also, the evaluate labels was set to true. for the first file with _A.ext as ending, it entered the sequence correctly but for the second file (/[^_C.ext]/), with _C.ext, it again entered the A sequence.


Hi Ruturaj,

can you provide a Screenshot of your Branch sequence please?

This might help us to understand whats going wrong.

Did you try the other way by specifing the remotefile as a variable to the branch and just leaving the regex (i.e. /[^_A.ext]/) as the label?
Evaluate labels should be set to false then.

Please have a look at the Service Development Help document if there is a note or explanation how to use regex on branches.


Please find the screen print below.

Your regex is wrong. “[^…]” means one character (an arbitrary one but not one from […]). Try %remotefile% == /.*_A.ext$/

Hello fml2,

The regex expression you gave worked. Appreciate your help.