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

branch and regular expressions

  • 1.  branch and regular expressions

    Posted 05/04/06 02:38 PM

    hello

    The branch that i test is
    switch on /string (evaluate labels = false)
    /part [023]555-A/:sequence

    i have a regular expression
    /part [023]555-A/

    those string match only for the strings
    part 0555-A
    part 2555-A
    part 3555-A
    this string will not match
    part 02555-A

    if i use only the expression
    /[023]/
    the precedent functions will match for all precedents strings

    that’s not the result expected.

    If i try with the service of PSUtilities
    PSUtilities.regex:matches
    all is as expected

    do you have any advise ?

    thanks in advance


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


  • 2.  RE: branch and regular expressions

    Posted 05/04/06 04:36 PM

    Use /part [023]+555-A/
    where the + indicates one or more instances of characters from the set, which I assume is what you’re after. If not please advise and we can get the right expression to use.

    This worked with both a branch label and with PSUtilities.regex:matches (without the surrounding /).

    My test with PSUtilities.regex:matches using
    part [023]555-A
    and value part 02555-A resulted in no match. I’m using IS 6.1 on JVM 1.4.2.


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


  • 3.  RE: branch and regular expressions

    Posted 05/04/06 04:41 PM

    One of my favorite regex resources is one of the regex testing pages at either [URL=“RegexPlanet: online regular expression testing for Java”]http://www.fileformat.info/tool/regex.htm[/URL] or [URL=“JavaScript RegExp Example: Online Regular Expression Tester”]http://regexlib.com/RETester.aspx.[/URL]

    The format of the regular expressions on this page may be slightly different than what you’d need in IS, but you can get the bulk of your regex pattern testing done here and then tweak for IS, if necessary.

    Mark


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


  • 4.  RE: branch and regular expressions

    Posted 05/05/06 09:33 AM

    reamon, what i want to is only to match the firsts tree strings not the forth one (with 0 AND 2)

    mcarlson, the results retrun by the javascript version and the asp version are different.

    are you agree with me that the regexp [023] or part [023]555
    both must match with
    part 0555
    but not with
    part 02555

    the thing i want to test is a string that begin with a string that contains only 0 or 2 or 3. Not two of the precent characters. i have no matter of "part " and “555”. that was to take the exemple of webMethods Developer User’s Guide page 415. i want that “^0$” or “^2$” “^3$” match but not “^02$”

    i don’t understand why regexp have different match on different languages implementations …
    i don’t understand the difference of interpretation between part[023]555 and [023] expect of course part and 555.

    i don’t think i’m very clear …

    thank’s in advance for your help

    ps : i’m using JVM 1.4.2 from sun and IS 6.1 too


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


  • 5.  RE: branch and regular expressions

    Posted 05/05/06 06:01 PM

    Then I think the expression you started off with, part [023]555, is the one you want for the example given.

    No. [023] will match when 0, 2, or 3 occurs anywhere within the string. It will, and should, match both your examples.

    To make sure I understand, you’re looking for a regex way of implementing this:

    BRANCH on someVar
    0: SEQUENCE (do something)
    2: SEQUENCE (do the same thing as 0)
    3: SEQUENCE (do the same thing as 0 and 2)
    $default: SEQUENCE (no match)

    If I understand what you’re after, then /^0$|^2$|^3$/should do what you want.

    Unless you anchor the regex with ^ or $ (beginning of string or end of string), then the pattern can occur anywhere within your string. Using your example, expression part [023]555 will match:

    part 0555-A
    part 2555-A
    part 3555-A
    junk part 3555-A fiddle faddle
    garbage part 0555xxxyyyzzz

    this string will not match
    part 02555-A

    But [023] will match all of them. Because this expression says “match if 0, 2 or 3 occur anywhere within the string.”


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


  • 6.  RE: branch and regular expressions

    Posted 05/08/06 03:33 PM

    wadouk,

    Seems to me that you want to ensure that the 1st character of the string is 0, 2, or 3 AND that the 2nd character of the string is NOT 0, 2, or 3. Is this correct?

    If so, then assuming that your string is at least 2 characters long, you can use this regular expression: /[1][^023]/

    Let me know if you need further clarification.

    • Percio

    1. 023 ↩︎


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


  • 7.  RE: branch and regular expressions

    Posted 05/09/06 03:08 PM

    Hello,
    if you need to match strings that only have one occurence of 0 or 2 or 3, then you have to use a regex like this:

    /[1][023][^023]$/

    this regex will match any strings like:
    (anything_except_023)0or2or3(anything_except_023),

    if You use /[023]/ only, it will match any string that have at least one 0 or 2 or 3,

    but if you need to match strings that have any occurence of 0 or 2 or 3, but at lest one of them is not precede by 0 or 2 or 3, then you need to use:
    /(^|[^023])023/

    this will match strings like:
    safa0safs0afsdf and sad02adfsd3test

    but not
    sassfd02sdafds

    and the third option if You one to match
    safa0safs0afsdf but not sad02adfsd3test

    than an expression like
    /^([^023](^|[^023])023[^023])*$/

    should be use:)
    this expression says that any occurence of 0,2,3 will not be precede by 0,2,3.

    hope, that helps,
    Kasper


    1. ^023 ↩︎


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


  • 8.  RE: branch and regular expressions

    Posted 10/13/06 05:51 PM

    If I want to switch based on date pattern, what will be the syntax?
    like yyyy-MM-dd, yyyyMMdd HH , etc.


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


  • 9.  RE: branch and regular expressions

    Posted 10/13/06 06:10 PM

    This is difficult to achieve… if you recieve a date like
    10/12/2006 it can be 10-Dec-2006 or 12-Oct-2006.


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


  • 10.  RE: branch and regular expressions

    Posted 10/13/06 06:19 PM

    Do we have date pattern matching syntax like string pattern matching in WM?


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


  • 11.  RE: branch and regular expressions

    Posted 10/13/06 07:05 PM

    yyyy-MM-dd, new pattern yyyyMMdd HH – dateFormat service should show as 20061013 00…You dont need mm ss??

    HTH,
    RMG


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


  • 12.  RE: branch and regular expressions

    Posted 10/13/06 07:12 PM

    I want to use different dateTimeFormat service based on different current patterns using branch.


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


  • 13.  RE: branch and regular expressions

    Posted 10/13/06 07:30 PM

    “different current patterns” do they provided you a list?? …Here is the goog search that came with
    [URL=“Date and Time Formats”]http://www.w3.org/TR/NOTE-datetime[/URL]


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


  • 14.  RE: branch and regular expressions

    Posted 10/13/06 08:03 PM

    I don’t think you can use webMethods branch service to achieve something based on a patter of the date…


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


  • 15.  RE: branch and regular expressions

    Posted 10/13/06 09:09 PM

    You would have to know the pattern you are receiving in advance, from a standard, by agreement with a partner or from an indicator elsewhere in the data. There’s no way to determine it from the date alone. Retrieve the pattern from wherever it is stored, translate it to a consistent format of your choosing, map it to a string variable and branch on the value of that.

    Tim


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


  • 16.  RE: branch and regular expressions

    Posted 10/15/06 01:58 AM

    You must have the patterns that you are expecting to receive and then use branch operation and translate it to expected format.simple say there is no dyanamic way…

    HTH
    RMG


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