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(")"))

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