One Star

tMap : Java functions 'Ereplace' and 'Change' not working

Hi,
we're trying to use 'Ereplace' and 'Change' functions in expression builder of tMap component, but the result we get when testing it is ',,,,,,' (see screenshot attached).
Did we miss a step with these functions ?
Thx for your answer
EMahe
5 REPLIES
Employee

Re: tMap : Java functions 'Ereplace' and 'Change' not working

Hello,
Actually , the first parameter of this method is a regular expression.
You have to replace "." by "\." to get the correct result.
Regards,
One Star

Re: tMap : Java functions 'Ereplace' and 'Change' not working

I have the same issue when trying to tmap a phone number from 11.111.1111 to 11-111-1111
Using StringHandling.EREPLACE(row1.HomePhone,".","-")
Gives the result of ---------
Using the "\." gives error Invalid Escape sequence.
Using "/." replaces nothing.
Please advise.
Community Manager

Re: tMap : Java functions 'Ereplace' and 'Change' not working

Hello
Try
StringHandling.EREPLACE(row1.HomePhone,"\\.","-")

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tMap : Java functions 'Ereplace' and 'Change' not working

shong,
Excellent! That worked.
Now my question is what special characters require the \\ so they don't confuse tMap
Thanks!
One Star

Re: tMap : Java functions 'Ereplace' and 'Change' not working

Hi,
Is one better to use in certain circumstances than the other (referring to Ereplace vs. Change)?