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

string replace using regular expression

  • 1.  string replace using regular expression

    Posted Tue January 05, 2010 11:06 PM

    I would like to remove ISC header info before the error message. Hence I am using string replace using regular expression.

    [ISC.0082.9034] Field is absent, field must exist.

    The regular expression I am using in search field is /^[ISC/… But I am getting the below error.

    org.apache.oro.text.regex.MalformedPatternException: Unmatched in expression.
    I know there are other solutions. But Just want to know what am I doing wrong in this case.

    Thanks
    Srinivas


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


  • 2.  RE: string replace using regular expression

    Posted Tue January 05, 2010 11:55 PM

    The [ has special meaning in regex. If you want to use it literally, escape it.


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


  • 3.  RE: string replace using regular expression

    Posted Wed January 06, 2010 01:16 AM

    /^[ISC.*] /

    assuming that there are no other closing square brackets with a following space in your string.


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


  • 4.  RE: string replace using regular expression

    Posted Thu January 07, 2010 11:10 PM

    Chris
    My inputs for string.replace service are
    inString---->[ISC.0082.9034] Field is absent, field must exist
    searchString----->/^[ISC.*] /
    replaceString----->X
    useRegex----> true

    My output value is still the same

    [ISC.0082.9034] Field is absent, field must exist. So can you let me know if I am missing something.

    I am expecting X Field is absent, field must exist for the output value.

    Thanks for your help.
    Srinivas


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


  • 5.  RE: string replace using regular expression

    Posted Fri January 08, 2010 01:30 AM

    Remove the enclosing slashes.

    My inputs for string.replace service are
    inString---->[ISC.0082.9034] Field is absent, field must exist
    searchString----->^[ISC.*]
    replaceString----->X
    useRegex----> true


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


  • 6.  RE: string replace using regular expression

    Posted Fri January 08, 2010 03:18 AM

    Hi Srinivas,

    I’m not sure we can use regular expressions in replace function to define a boundary and replace them with a single char but if your requirement is to just delete the error code from the error message then this is my suggestion: Form a regular expression which would pattern match numberics(0-9) and ‘.’ which would start with [ISC and end with ‘]’ and and leave the replaceString empty. This would remove the error code.

    BUT BEWARE that this would remove any other numbers and . in the whole message.

    Another way you can do is to do a 3 step.

    [INDENT]1. indexOf(“]”)
    2. substring(0,index)
    3. replace(substring,replaceString=“”)
    [/INDENT]
    Hope this helps.

    -Suren


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


  • 7.  RE: string replace using regular expression

    Posted Fri January 08, 2010 07:05 AM

    Hi,

    If you will use Search String as ^[ISC.*] it will work fine.

    cheers!
    nD


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


  • 8.  RE: string replace using regular expression

    Posted Fri January 08, 2010 04:55 PM

    To elaborate, the surrounding slashes on a regex are only needed when regex is used as a label in a branch step. Other facilities that support regex do not need them.


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


  • 9.  RE: string replace using regular expression

    Posted Fri January 15, 2010 03:57 PM

    Thanks Guys, It worked with your inputs.


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