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 for numbers in webMethods 10 is not working

  • 1.  Regular expression for numbers in webMethods 10 is not working

    Posted 06/08/23 09:27 PM

    webMethods10.7

    I’m trying to generate an email template using the variables. Im using %ifvar% constructor… My sample code is;

    %ifvar isFuture equals(‘1’)%
    %ifvar dayGap matches(‘/([0-9]|[1-9][0-9]|[1-9][0-9][0-9])/’)%

    %value info/subj%
    %value info/valid%
    %value info/is%

                    </TR>
    %else%
    <TR valign="top" bgcolor= #eeeeee >
    <TD>%value info/subj%</TD>  
    <TD>%value info/valid%</TD>  
    <TD>%value info/is%</TD>  
    
    </TR>
    %endifvar%
    

    %else%

    im trying to match the “dayGap” variable to 1-1000 numbers. But it is not working… May I know what is wrong here? does webMethods support reg ex for numbers?

    p.s: I tried the following combinations too

    • %ifvar dayGap matches(‘^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$’)%
    • %ifvar dayGap matches(‘([0-9]|[1-9][0-9]|[1-9][0-9][0-9])’)%


    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/09/23 02:27 PM

    The / / that surround the regex are not needed in this context. Those are for step labels to indicate a regex is being used.

    An alternative to consider:

    ^(?:0|[1-9]\d{0,2})$
    

    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/13/23 09:25 PM

    Hi Reamon; Thanks for the help…SO I changed the template like;

    %ifvar dayGap matches(‘^(?:0|[1-9]\d{0,2})$’)%

    %value trustS%

    But it didnt work…
    May I know waht is the number range it checks with below regex.?

    ^(?:0|[1-9]\d{0,2})$’


    #webMethods
    #Integration-Server-and-ESB


  • 4.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/13/23 11:16 PM

    0 through 999

    ^ - anchor to the beginning of the string
    (?: - non-capturing version of parentheses
    0 - match zero
    | - or
    [1-9] - digits 1 through 9
    \d - any digit
    (0,2) - 0, 1, 2 repeat of previous
    $ - anchor to end of the string

    Have you confirmed dayGap is present and has a value? (Equivalent of “is it plugged in” but I gotta ask :slight_smile: )


    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/13/23 11:30 PM

    Hi raemon;
    Thanks… Yes daygap is present…

    %ifvar dayGap matches (‘^(?:0|[1-9]\d{0,2})$’)%

    %value trustS% ....
    </TR>
    

    %else%

    %value trustS%

    I always get at else block whenever my daygap values changes to 1-3000


    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/14/23 10:00 AM

    Forgive me but I do not see evidence that dayGap has a value, or what value it has. Do you have screen shot or something that shows its value?


    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/19/23 11:37 PM

    Hi Raemon; sorry my html code couldnt be pasted here…It removes the tags…Here i attch the screenshot of html code…Please have a look and tell me…When my daysremaining variable contains 1-3000 value, i would like to change a colour for 1-100 and one for >100 another colour…Here it always falls in else block…


    my days remaining values are 35, 215, 733, 3461…and it prints that value for a column…


    #webMethods
    #Integration-Server-and-ESB


  • 8.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/20/23 01:08 PM

    I assume daysRemaining (previously dayGap?) is a child element within sortedCerts? Possible scoping issue.

    Can you share the doc list structure screen shot? Perhaps the Results tab showing the pipeline of the service once it has obtained its list of sortedCerts. Still don’t see evidence that daysRemaining is populated but I guess I’ll trust that you see 35, 215, etc.

    Might I suggest a possible simplification of the DSP. No need to repeat all the <TD> tags for all the fields. Use the ifvar to “write” the <TR> as desired (with or without highlight) followed by one set of the fields.

    %ifvar daysRemaining matches ('^(?:0|[1-9]\d{0,2})$')%
    <TR valign="top" bgcolor=#FFDB00>
    %else%
    <TR valign="top" bgcolor=#eeeeee>
    %endif%
    
    <TD>%value trustStoreAlias%</TD>
    <TD>%value keystore% %value keyAlias%</TD>
    ...
    </TR>
    

    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/20/23 11:05 PM

    HI Reamon;
    Here is my document structure…It is in same root level like as other variables…
    Capture

    And also I changed the html as you suggested…But same results…It always falls under else loop and i get my rows in ‘D3D3D3’ colour…

    My final template output comes as (to show remaining days printed, grey colour D3D3D3 background)

    May I know what is wrong here?


    #Integration-Server-and-ESB
    #webMethods


  • 10.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/21/23 01:18 AM

    I’m not attempting to answer the original question, but just want to recommend online regex testing services like https://regex101.com/ – they are a great way to test, validate and understand regexs.


    #webMethods
    #Integration-Server-and-ESB


  • 11.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/21/23 10:56 PM

    Thanks for that tutorial link and I tried this

    ^(?:0|[1-9]\d{0,1})$

    Regular expression which matches the numbers between 1-100…So I expect my row colour should change but it is not working as expected…
    That is what im looking for help here…


    #webMethods
    #Integration-Server-and-ESB


  • 12.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/22/23 12:19 AM

    @Ratha_v - ana, here’s another, possibly simpler, regex:
    ^\d{1,2}$|^100$

    ^\d{1,2}$ matches one or two digits and covers 0-99. The ^100$ just checks for ‘100’.

    I tested the regex above and saved the regex query here. The blue highlights shows how the regex matches numbers from 0 to 100, but does not match other numbers or values.
    image.

    But try avoiding regexs when possible. For instance, you could calculate a cert_alert variable (true/false) in your Flow code and change the DSP background based on its value.

    Personally, regexs intimidate me somewhat. :smiley: There’s this famous saying: :smiley:

    Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.


    #Integration-Server-and-ESB
    #webMethods


  • 13.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/22/23 01:29 AM

    I went with the variable option as you said…and its working charmly than regex…


    #Integration-Server-and-ESB
    #webMethods


  • 14.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/22/23 03:18 AM

    Glad to hear it ana! :smiley: It’s more maintainable than regular expressions.

    webMethods really should make %ifvar% support math operations like >=, <, etc


    #Integration-Server-and-ESB
    #webMethods


  • 15.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/26/23 01:09 PM

    Debatable, but I do understand the concern about regex. Easy to get them wrong. As with many computing topics, takes time to understand and get comfortable with them. :slight_smile:

    It is likely that “regular expression” in the DSP context is not regular expressions at all. Found this from years ago:DSP regular expressions (ifvar matches)

    “It just uses * and ? as kind of wild card.”

    This is from Xiaowei Wang back in 2015. In that thread he indicates he patched it to make it support regex – but that would apply to his own installation.

    So mystery solved I think – ifvar matches support wildcards, not regex. Even the example in the help doc for ifvar implies this:

    For example: %ifvar carrier matches(‘UPS*’)%.

    If that were regex, it would match strings starting with UP followed by 0 or more S chars. Unlikely to be useful. A regex for this would be ‘UPS.*’

    Documentation bug IMO. And would be nice if in addition to the math operators it would support regex (and maybe wildcards).


    #Integration-Server-and-ESB
    #webMethods


  • 16.  RE: Regular expression for numbers in webMethods 10 is not working

    Posted 06/27/23 02:33 AM

    Very true. I should have clarified my comment was specific to using regexs with %ifvar% – a match not made in heaven.

    Very nice work Rob! That makes sense.

    I was just musing this wildcard-based construct may work for matching 0-100 days (assuming ‘?’ matches one digit).

    %ifvar var matches('?')%
    ...DO STUFF...
    %else%
    %ifvar var matches('??')%
    ...DO STUFF...
    %else%
    %ifvar var matches('100')%
    ...DO STUFF...

    #Integration-Server-and-ESB
    #webMethods