简体   繁体   English

Informatica-替换目标中的字符

[英]Informatica - replace characters in target

Im working in a project which we create hundreds of xml's in informatica everyday, and all the data which is in the xml should be filtered, like removing all kind of special characters like * +.. You get the idea. 我在一个项目中工作,我们每天都会在informatica中创建数百个xml,并且应该过滤xml中的所有数据,就像删除* *等各种特殊字符一样。

Adding regular expressions for every port is too complicated and not possible due the large amount of mapping we have. 为每个端口添加正则表达式太复杂,由于我们拥有大量映射,因此无法实现。

I've added a custom property to the session XMLAnyTypeToString=Yes; 我已经向会话XMLAnyTypeToString = Yes添加了一个自定义属性; and now i get some of the characters instead of &abcd, in their usual presentation (" + , ..). 现在,在他们通常的演示中,我得到了一些字符而不是&abcd(“ +,..)。

I'm hoping for some custom property or change in XML target to remove these characters completely. 我希望有一些自定义属性或更改XML目标以完全删除这些字符。 any idea? 任何想法?

You can make use of String.replaceAll method: 您可以使用String.replaceAll方法:

  String replaceAll(String regex, String replacement) Replaces each substring of this string that matches the given regular expression with the given replacement. 

You can create a set of symbols you want to remove using regex, for example: 您可以使用正则表达式创建一组要删除的符号,例如:

[*+"#$%&\(",.\)]

and then apply it to your string: 然后将其应用于您的字符串:

String myString = "this contains **symbols** like these $#%#$%";
String cleanedString = myString.replaceAll("[*+"#$%&]", "");

now you "cleanedString" is free of the symbols you've chosen. 现在,您的“ cleanedString”中没有选择的符号。

By the way, you can test your regex expression in this excellent site: http://www.regexplanet.com/advanced/java/index.html 顺便说一下,您可以在这个出色的网站中测试您的正则表达式: http : //www.regexplanet.com/advanced/java/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM