informaticainformatica-powercenterinformatica-data-integration-hub

How to write regex or any replace function to replace with null where [,-] pattern exist


I am trying to create logic using informatica to replace wherever ',' followed by '-' exist [,-] replace with null.

Input :

abc-cde@gmail.com,-cde@gmail.com,-efg@gmail.com
ghi@gmail.com,-acf@gmail.com

Output :

abc-cde@gmail.com,cde@gmail.com,efg@gmail.com
ghi@gmail.com,acf@gmail.com

I have tried REPLACESTR,REPLACECHAR but its not working as pattern its considering both of them as single character and replacing wherever it is , or -.I need to build logic where it consider it as pattern of ,followed by - and then replace.


Solution

  • Please show your code, as most likely you're doing something wrong. The REPLACESTR function should be working perfectly fine in your scenario.

    Syntax:

    REPLACESTR ( CaseFlag, InputString, OldString1, [OldString2, ... OldStringN,] NewString ) 
    

    Check this example:

    REPLACESTR( 1, WEBLOG, '"', 'GET ', ' HTTP/1.1', NULL )
    

    Input:

    "GET /companyinfo/index.html HTTP/1.1"
    

    Result:

    /companyinfo/index.html
    

    Seems the following should work for you:

    REPLACESTR( 1, inputField, ',-', NULL )