Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

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
Highlighted
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,
Highlighted
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.
Highlighted
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
Highlighted
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)?

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog