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.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

Regular Expression to check a field for two values.

  • 1.  Regular Expression to check a field for two values.

    Posted 07/25/12 04:26 AM

    Hello There,

    How can we check a filed for two values.

    I am currently using this expression in the label of one of the sequence:

    %fieldName%==/A|B/

    But, the above expression is not working…Any other thoughts please?

    Thanks,
    rAm


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


  • 2.  RE: Regular Expression to check a field for two values.

    Posted 07/25/12 05:50 AM

    BRANCH on fieldName
    /A|B/ : SEQUENCE

    In labels, the regex needs to start and end with /.


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


  • 3.  RE: Regular Expression to check a field for two values.

    Posted 07/25/12 06:37 AM

    [ATTACH=CONFIG]867[/ATTACH]

    HTH
    Senthil


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


  • 4.  RE: Regular Expression to check a field for two values.

    Posted 07/25/12 03:50 PM

    Hi Senthil,

    The condition you suggested will work only if the ‘input’ value starts with either A or B. I was looking for a check that satisfies if the input value is either ‘A’ or ‘B’.

    Veera.

    [ATTACH=CONFIG]868[/ATTACH]
    test.PNG


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


  • 5.  RE: Regular Expression to check a field for two values.

    Posted 07/25/12 06:47 PM

    I was mistaken. The label can indeed be an expression as you’ve listed. I tested this with success:

    (The … are just to show indentation)

    BRANCH (evaluate labels set to True)
    …%input%==/^A$|^B$/ || %input%==‘C’: SEQUENCE

    All test variations perform as expected–only a stand-alone A, B or C matches.

    [Edit] My personal preference is to avoid evaluate labels when possible. For your scenario, you could use:

    BRANCH on ‘/input’
    …/^A$|^B$|^C$/: SEQUENCE (do something when input is A, B or C
    …D:SEQUENCE (do something else when input is D)
    …$default: SEQUENCE (do something new in all other cases)


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


  • 6.  RE: Regular Expression to check a field for two values.

    Posted 07/25/12 08:09 PM

    Hi Reamon,

    The condition that you suggested before(/A|B/) does work for FieldName starts with A or B, but , i was looking for to check FieldName that has value of only A or B.

    But, the condition that you posted in the latest thread (…%input%==/^A$|^B$/ || %input%==‘C’) works absolutely fine. For the scenario i’m looking for.

    As you said, Evaluate labels should be avoided, but in my case it is required i guess. As i am validating two different fields (My Bad, That i have not mentioned correctly in my previous post), but you could observe the requireent by seeing the below screenshot.

    In the below screenshot the first condition satisfies my requirement, but the second one doesn’t.

    Thanks Reamon,
    Veera.[ATTACH=CONFIG]869[/ATTACH]
    test.PNG


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


  • 7.  RE: Regular Expression to check a field for two values.

    Posted 07/25/12 11:43 PM

    Just for clarification…

    /A|B/ will match if A or B appears ANYWHERE within the variable value. Thus, it would match on foobAr, fooBar, Fozzy Bear, Barney Rubble, Kyle Broflovski, Jennifer Aniston, etc.

    /^A|^B/ will match any value that starts with A or B.

    ^ - indicates the start of the string
    $ - indicates the end of the string


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


  • 8.  RE: Regular Expression to check a field for two values.

    Posted 07/26/12 04:58 AM

    Guys… got a doubt… If you just have only 2 values to be compared absolutely, why should you look for regular expression… Regex is specifically for matching the patterns of strings… Why not just use the generic logical operator that makes the comparison? Or am I missing something obvious in the use-case?

    -Senthil


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


  • 9.  RE: Regular Expression to check a field for two values.

    Posted 07/26/12 05:38 AM

    Senthil,

    I was like curious to know this one. Moreover, In our code the path of the fields that we check were very long, so was looking for regular expression…

    Thanks Senthil,
    Veera


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


  • 10.  RE: Regular Expression to check a field for two values.

    Posted 07/26/12 06:04 AM

    Hmm… I would do this to reduce the path of the field. Add a map step before the Branch, and map the values to temporary variables… These variables can be used in Branch which will give more readability…

    HTH
    Senthil


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


  • 11.  RE: Regular Expression to check a field for two values.

    Posted 07/11/16 06:33 PM

    One funny thing that happened his. I was struck with the same question again and i found my own post, which i realized it is me after a while of reading all the comments :). Anyways if we add $ symbol all the way in the end it of each word which will give us the expected outcome.

    Attaching a screenshot.
    Service_Development_-10_70_17_6_5555_Default_Default_veera_regex-Software_AG_Designer-__Users_veera_chitturi_workspace99.png


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