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