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

Variable substitution inside Regular Expression.

  • 1.  Variable substitution inside Regular Expression.

    Posted Wed September 13, 2006 03:45 AM

    Hi Gurus,

    I am using Branch with Regular expression.

    Code :

    Two variables in pipeline.
    testStr = abc
    validStrList = abc|xyz|efg
    BRANCH - Evaluate Label = False, Switch on /testStr
    SEQUENCE - Label = /%validStrList%/

    As you can see I would like to peform variable substitution before evaluation the regular expression. This is not working.

    If I hard code values of validStrList in regular expression it works.

    Has any one tried this? Or any other suggestions, workarounds??

    Appreciate your help.
    Ajit


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


  • 2.  RE: Variable substitution inside Regular Expression.

    Posted Wed September 13, 2006 10:27 AM

    When you are doing a variable substitution you need to set the Evaluate Label to True.


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


  • 3.  RE: Variable substitution inside Regular Expression.

    Posted Wed September 13, 2006 05:31 PM

    Ajit,

    Try this:
    In addition to your to your testStr and validStrList create another var evaluateStr and set its value to the expression that you want to evaluate, ie hardcode %testStr% == /%valStrList%/ into evaluateStr and check mark ‘Perform Variable Substitution’ when hardcoding the value. Now create your branch as follows:

    Branch [Evaluate Label = True]
    – Sequence [Label = %evaluateString%]
    ---- Do your stuff here
    – Sequence [Label = $default]

    Hope this helps

    ~ Rohit


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


  • 4.  RE: Variable substitution inside Regular Expression.

    Posted Thu September 14, 2006 04:29 AM

    Thanks Rohit and altgecko,

    I was very much convinced with Rohit’s solution, but its not working either…

    I tried it. I dont think we can put regular expression with variable substitution…

    Rohit can you please give it a quick go… It alwas goes in first sequence cause lable %evaluateString% means if evaluateString exist or not null then go in… and it does exist as "abx == /abc|xyz|efg/ " I also tried with value of evaluateString = “/abc|xyz|efg/”, still dont work…

    I believe for Regular Expression we have to use evalute label equal to false but then we can not do variable substitution to have regualar expression dynamic…:frowning:

    :frowning:

    Thanks…


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


  • 5.  RE: Variable substitution inside Regular Expression.

    Posted Thu September 14, 2006 09:20 PM

    My bad! Yes it goes to the first sequence because the var evaluateString exists in the pipeline. Hmmm I tried it many other ways but nothing seems to be working.

    I think you’ll need to use other ways of determining whether your input var (testStr) is valid or not - you know, by tokenizing valStrings, looping over tokens and then branching… unless u find a way of doing this. If so please do share it with us.

    ~ Rohit


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


  • 6.  RE: Variable substitution inside Regular Expression.

    Posted Fri September 15, 2006 12:30 AM

    Thanks Rohit,

    I know the tokenizing way to doing it… I am already doing it at some other place but I believe it will be bit expesive than regular expression… But doesnt look like there is any other way…

    Thanks for your inputs guys… Atleast its clear now…

    Cheers,
    Ajit


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


  • 7.  RE: Variable substitution inside Regular Expression.

    Posted Tue September 19, 2006 03:09 PM

    Perhaps I’m not understanding the problem correctly, but I think you can do this using PSUtilities, as long as you’re running at least JVM 1.4. Before you do your BRANCH, call PSUtilities.regex:matches and map testStr to ‘input’ and validStrList to ‘regex’. Then BRANCH on the value of ‘match’ (true or false) to decide which sequence to take. HTH,

    Tim


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


  • 8.  RE: Variable substitution inside Regular Expression.

    Posted Wed September 20, 2006 05:20 AM

    Thanks Tim,

    PSUtilities.regex:matches service did the job. Apologies for troubles guys. I should have checked PSUtilities before hand…

    Ta,
    Ajit


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


  • 9.  RE: Variable substitution inside Regular Expression.

    Posted Sun November 26, 2006 05:17 PM

    Variable substitution is not supported for regular expression in branch step. i had to wrote a small java service using java.util.regex.* for building my own rule engine.

    Advantage site also listed this problem as unsupported.
    [url]https://advantage.webmethods.com/advantage?targChanId=kb_home&oid=1613807838[/url]

    Thanks
    Ravi


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


  • 10.  RE: Variable substitution inside Regular Expression.

    Posted Fri June 09, 2017 06:51 AM

    I had some similar requirement where I had to substitute a pipeline variable in regex pattern .

    I added a map step for substituting the pipeline variable in regex pattern and then passed it to PSUtilities.regex:matches


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