One Star

tReplace Java

Hi,
I'm new to talend but not etl. I am trying to use the java tReplace component and have a problem stripping + signs from a field.
I have a tFileInputDelimited pipe delimited input file connected to tReplace and then connected to a tFileOutputDelimited pipe delimited output file. In simple mode I have "+" in the search and "" in the replace. The error I get is:
Exception in component tReplace_1
java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 4
(?i)+
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at test.replacetest.replacetest.tFileInputDelimited_1Process(replacetest.java:344)
at test.replacetest.replacetest.runJobInTOS(replacetest.java:689)
at test.replacetest.replacetest.main(replacetest.java:606)
This has got be user error I'm just not sure what my error is. Any help would be appreciated.
Thanks,
Chris
2 REPLIES
Community Manager

Re: tReplace Java

Hello Chris
Try "\\+".
Thank you for your interest in Talend Open Studio.
If you have any questions please do not hesitate to submit on forum or contact us.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tReplace Java

Hello,
where can I find document explaining how works each component of Talend, like tReplace, tjoin.....??
I am trying to delete the 2 first lines of a ldif file. I was trying to use the replace by "empty", but not result. Or is it possible to use an attribute in the dn but to hide it, exclude it from the "entry" description. here is my example:
dn: initials=WO,ou=Contacts,dc=iee,dc=lu
changetype: add
dn: initials=WO,ou=Contacts,dc=iee,dc=lu ///// would like to not have this one, or not have the first one. But the first one is generated // ///automatically by Talend.
initials: WO
mail: wonkelinx@salesforce.com
modifytimestamp:
givenName: Wilfried
objectclass:
cn: Wilfried Onkelinx
sn: Onkelinx
homePhone:
mozillaHomeLocalityName:
mozillaCustom4:
mobile:
mozillaCustom3:
mozillaCustom2:
company: Salesforce.com
postalCode: B 11
mozillaCustom1: Male
nsAIMid:
telephoneNumber: +32 2 535 78 25
street: nullStephanie SquareAvenue Louise - Louizalaan 65
Could someone help me please.
Thanky anyway.