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

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
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!
Highlighted
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)?

What’s New for Talend Spring ’19

Join us live for a sneak peek!

Sign up now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download