用正则表达式或任何替换函数来替换出现 [,-] 模式的部分为空。

huangapple go评论41阅读模式
英文:

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

问题

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 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.

答案1

得分: 0

请展示你的代码,因为很可能你做错了什么。在你的情况下,REPLACESTR函数应该是可以正常工作的。

语法:

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

请参考这个例子:

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

输入:

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

结果:

/companyinfo/index.html

看起来下面的代码应该适合你的需求:

REPLACESTR( 1, inputField, ',-', NULL )
英文:

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 )

huangapple
  • 本文由 发表于 2023年3月31日 02:04:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75891553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定