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

Regular Expression

  • 1.  Regular Expression

    Posted Mon June 13, 2005 01:09 PM

    Hi All,

    Iam trying to BRANCH on a variable that variable should contain a number, so if the variable contains a number then in should process one SEQUENCE, if that variable contains other than number it has to process $default:SEQUENCE.
    For that iam using the regular expression, in webMethodsDeveloper.pdf it was given for \d Match any digit. Same as [0-9].
    Example doc.p[/part \d555-A/].text
    I have tried so many possiblities.
    What is the REGULAR EXPRESSION for the number (only).

    Thanks in advance.


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


  • 2.  RE: Regular Expression

    Posted Mon June 13, 2005 01:25 PM

    Hi ,
    The expression is %char% = /[0-9]/ for comparing whether a char is numeric or not.Also make sure you set Evaluate-Labels property of Branch step to True.


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


  • 3.  RE: Regular Expression

    Posted Mon June 13, 2005 02:04 PM

    Hi bhaskar,

    i did the same but its not working.
    the error is
    com.wm.lang.flow.FlowException: [ISC.0049.9012] Cannot define switch and use label conditions at ‘unlabeled BRANCH’

    this error comes when i set Evaluate-Labels property of Branch step to True.


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


  • 4.  RE: Regular Expression

    Posted Mon June 13, 2005 02:18 PM

    RKK,
    Just make sure you dont have anything set in the switch property of Branch.Just select Evaluate labels to ‘true’ over there.Inside the Branch step give the expression as given by Bhaskar in the labels of child steps.Your problem will be solved.

    Thanks,
    Puneet Verma


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


  • 5.  RE: Regular Expression

    Posted Mon June 13, 2005 02:21 PM

    Hi,

    i hope u r putting ‘char’ in Branch step with Lebel=True, which will not work, so do like this,
    Branch Evaluate -Label=True,
    in Sequence step, mention %char%=/[0-9]/ at Label property.


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


  • 6.  RE: Regular Expression

    Posted Mon June 13, 2005 02:56 PM

    Hi Bhaskar and Puneet,

    i have kept %char%=/[0-9]+$/ in the sequence label.
    i have included only +$ to get if there are more that one digit and its working.

    Thanks for the help guys.


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


  • 7.  RE: Regular Expression

    Posted Wed June 15, 2005 01:50 PM

    Hi All,

    Do we have any difference between a Java REGULAR EXPRESSION’s and a webMethods REGULAR EXPRESSION’s.

    My filename is Date_DBILL_date_time.DAT
    I have to find the DBILL in the file name using regular expression and ftp it to the corresponding folder.
    How should i give it.

    Thanks In advance.
    RKK


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


  • 8.  RE: Regular Expression

    Posted Wed June 15, 2005 03:11 PM

    There are a few posts here on Regex examples and I think even an eZine article. Here is a basic primer on regular expressions.

    Mark


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


  • 9.  RE: Regular Expression

    Posted Wed June 15, 2005 04:32 PM

    Try this:

    BRANCH on ‘/filename’
    …/DBILL/: SEQUENCE (filename contains DBILL)

    Appendix B in the Developer’s Guide describes the regex facilities in IS.


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


  • 10.  RE: Regular Expression

    Posted Thu June 16, 2005 11:02 AM

    Hi Rob Eamon

    It’s working thanks for the help

    But one more question in Developer guide the regular expression is doc.p[/\bport\b/].text but /DBILL/ is working.

    Is there any difference between the java regular expressions and webMethods regular expressions.

    Plz clarify my doubt. So that I can move further in using the regex.


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


  • 11.  RE: Regular Expression

    Posted Thu June 16, 2005 03:51 PM

    The Developer guide focuses on using regular expressions when using WQL in the pub.xml:queryXMLNode service, thus the doc.p references throughout. In the many examples provided in the doc, you can use the text within and including the slashes. For the example,

    doc.p[/\bport\b/].text

    you could use the /\bport\b/ within a BRANCH switch label to test if the BRANCH variable has the whole word “port” within it.

    The article Mark referenced is at
    [url=“wmusers.com”]wmusers.com

    As for wM regex compared to Java 5.0/1.5 there are probably differences but in a cursory review, I haven’t seen any that I could point out. Since wM regex predated the Java regex we shouldn’t be surprised if there are a few though. Sun says Java regex is similar to Perl regex ([url=“java.util.regex (Java 2 Platform SE 5.0)”]JDK 19 Documentation - Home).

    A summary of the Java regex constructs is located at [url=“Pattern (Java 2 Platform SE 5.0)”]JDK 19 Documentation - Home

    I use a little regex test service to verify that any of the regex constructs I create do exactly what I need.

    Service: RobSandbox:regexTest
    Input: input (string)
    Output: result (string)

    BRANCH on ‘input’
    …/DBILL/: MAP (Put your regex in the label here. Map sets result to “hit”)
    …$default: MAP (Map sets result to “no hit”)

    When the service is run in Developer, you get prompted for input and the output shows whether the regex matches the input or not. This makes it easy to test various input conditions, such as null variable, empty variable, only spaces, “real” content, etc. Once my regex is “debugged” I copy it to the real place in the integration where it is needed.

    HTH


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


  • 12.  RE: Regular Expression

    Posted Tue July 12, 2016 07:35 AM

    Hi,
    Can you please help me for regular expression. my requirement is if variable contain char then only its execute remaining code otherwise it will go to exit $flow.

    Now i am using %char%== “/[A-Za-Z]/”

    Regards
    Hariom


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


  • 13.  RE: Regular Expression

    Posted Fri July 15, 2016 04:07 PM

    Hariom,

    Here is the simple logic to check the condition as for your needs:

    Service Snippet as an Example:
    Create a new service "testChars" → Logic as follows

    Map (testChar) - service input and pass some chars)
    Branch Evaluate -Label=True,
    (under Inside this branch)
    Add Sequence step, mention %testChar% ==/[A-Za-z]/ at Label property.
    –>If the testChar has chars the step inside this sequence executes else
    Add another Sequence step (select $default at Label property)
    → Add EXIT $flow step

    Try the above and test the flow and it should work. :smiley:

    HTH,
    RMG


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


  • 14.  RE: Regular Expression

    Posted Sat July 16, 2016 04:15 AM

    I agree with RMG. Give a try and update if you see any issues.

    Thanks,


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