Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
gtaware
Contributor
Contributor

String Handling in Talend

Hi All Experts ,

 

I have multiple cases I am handling in Tmap .

 

 

Case 1 : 

 

 I have string like "125,12NC"  

 

  How to remove  Alphabetic characters from above string in Tmap ?

 

Case 2 : 

 

 I have string like : 

"1812281228C125,12NCOL851711644078226,851711644078226 NG KIM LAI"

 

Out of this string , I have to take  only last  string which is have splitted using below function 

 row7.data.split(",") [ 2 ]  

 

But instead of '2' i have to put a generic code which will take a last index only in [] . How to do that ? 

I tried using 

row7.data.split(",") [ row7.data.lastIndexof(",")]   

 

But this did not worked out . 

 

Can you please help me how to  achieve above scenarios . 

 

 

 

Labels (3)
4 Replies
Raghuram_Puram
Contributor III
Contributor III

For Case 1:

Use replaceAll([^a-zA-Z], "") in tMap expression builder to get rid of Alphabets.

 

For Case2:

Put your desired value in a context variable(mind the datatype it should be int) and use that in split function.

row7.data.split(",",context.value) ;

 

Let us know if this helps.

dbeltritti
Contributor III
Contributor III

For Case 2: If you want always the last value then you can do

 

row7.data.split(",")[row7.data.split(",").length-1];

 

 

gtaware
Contributor
Contributor
Author

@ Raghuram ,

I have tried below expression but throwing me error ;

 

(row7.data.substring(11,19)).replaceAll([^a-zA-Z], "")

 

For Case 2 : 

I ant go with that solution . Because I  am not sure which Index  Number will be considered as last one . It may 1,2,3,4 ..based on our splitting .

gtaware
Contributor
Contributor
Author

Thanks . For Case 2 : That's a Right Solution .