Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tmap remove leading zeros from a string

I have a customer table (customer number and custumer name). Most of the custumers are integer, but some of them have a "L" in front of them. The custumer number is therefore type string. The problem is that the "integer" custumers have leading zeros - for instance 0000113934 which I can remove if I make it integer, but thats not possible with the custumers starting with "L" for instance L1993493.
I tried in the tmap to make the expression:
StringHandling.LEFT(row1.Customer_number,1).equals("0")?
StringHandling.STR(Mathematical.INT(row1.Customer_number),50): row1.Customer_number
But then I get the error:
The method STR(char, int) in the type StringHandling is not applicable for the arguments (int, int)
I also tried to filter the custumer numbers starting with zero in tmap and then putting the filtered output through tconverttype to cast it to integer and then another tconverttype to cast it back to string, but then when I use tunite with the other output from tmap where the custumer numbers does not start with zero I cannot get it to connect to the tunite.
Any good ideas?
Labels (2)
3 Replies
janhess
Creator II

You can't unite two outputs from the same tMap.
Have you tried
StringHandling.LEFT(row1.Customer_number,1).equals("0")?
Integer.toString(Integer.parseInt(row1.Customer_number)): row1.Customer_number
Anonymous
Not applicable
Author

Thanks a lot - that works just like intended.
alevy
Specialist

My 2 cents even though janhess's solution worked for you 0683p000009MACn.png : I like regex for these sorts of things as it's usually a neater expression so I would use:
row1.Customer_number.replaceAll("^0*","")