tMap extract customer number from string

Highlighted
One Star

tMap extract customer number from string

Hi,
I have a source cvs report that looks like this:
JOHN DOE COMPANY (144333),2344,1233,1233
I had to extract the customer number between parentheses, so I did:
StringHandling.LEFT((StringHandling.RIGHT(row1._Sales,7)),6) directly on the tMap field to match the customer number and get the ID as a lookup.
Now I have brought in another region that has 2 more digits on the customer number, so my previous solutions doesn't work. I've spent a good 5 hours reading solutions, but can't seem to find a solution. I'm not that good with regex and I want to make sure that I get the extraction right.
Please help!
Thanks!
OA
One Star

Re: tMap extract customer number from string

hello,
Try this
String foo = "JOHN DOE COMPANY (144333),2344,1233,1233";
foo.substring(foo.lastIndexOf("(")+1,foo.lastIndexOf(")"))

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads