tMap extract customer number from string

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
Highlighted
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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

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

Download