IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

USe of regular expressions in branch condition

  • 1.  USe of regular expressions in branch condition

    Posted Tue October 18, 2016 05:16 AM

    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.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: USe of regular expressions in branch condition

    Posted Tue October 18, 2016 08:09 AM

    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.

    Regards,
    Holger


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 3.  RE: USe of regular expressions in branch condition

    Posted Tue October 18, 2016 09:38 AM

    Tried that too, not working.

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


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 4.  RE: USe of regular expressions in branch condition

    Posted Tue October 18, 2016 09:42 AM

    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?


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 5.  RE: USe of regular expressions in branch condition

    Posted Tue October 18, 2016 11:26 AM

    Hi Venkat,

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

    -USED FOR RANGE OF VALUES

    hope this helps


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 6.  RE: USe of regular expressions in branch condition

    Posted Tue October 18, 2016 02:09 PM

    He is right, you will want to use :

    /^(VALUE)|(VALUE)$/

    starts with VALUE or ends with VALUE

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

    /(VALUE)/

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

    so

    %/IDOC[0]/SEGMENT1/SUBSEGMENT1/NAME%=/(?i)(VALUE)/


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: USe of regular expressions in branch condition

    Posted Wed October 19, 2016 07:31 AM

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


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: USe of regular expressions in branch condition

    Posted Wed October 19, 2016 02:39 PM

    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 .*?>/


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 9.  RE: USe of regular expressions in branch condition

    Posted Tue October 25, 2016 05:58 AM

    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.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 10.  RE: USe of regular expressions in branch condition

    Posted Tue October 25, 2016 06:07 AM

    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


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 11.  RE: USe of regular expressions in branch condition

    Posted Wed March 28, 2018 05:28 PM

    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?


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 12.  RE: USe of regular expressions in branch condition

    Posted Wed March 28, 2018 05:30 PM

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


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 13.  RE: USe of regular expressions in branch condition

    Posted Thu March 29, 2018 09:28 AM

    Hi,

    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]/”.

    Regards,
    Holger


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 14.  RE: USe of regular expressions in branch condition

    Posted Thu March 29, 2018 01:52 PM

    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.

    Regards,
    Ruturaj


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 15.  RE: USe of regular expressions in branch condition

    Posted Thu March 29, 2018 02:33 PM

    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.

    Regards,
    Holger


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 16.  RE: USe of regular expressions in branch condition



  • 17.  RE: USe of regular expressions in branch condition

    Posted Thu March 29, 2018 07:46 PM

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


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 18.  RE: USe of regular expressions in branch condition

    Posted Thu March 29, 2018 07:57 PM

    Hello fml2,

    The regex expression you gave worked. Appreciate your help.

    Thanks,
    Ruturaj


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services