Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
RP1629548713
Contributor II
Contributor II

Splitting of String in Talend

Hi All ,

I need a small help . I have an input ,e.g : ABC : 123 which is completely in string as it is a file . The length of this input may vary or i can say is dynamic. I need to extract only the right hand part from based on the delimiter which is ": " and whatever comes after the delimiter i need to store. The input that comes before the delimiter needs to be excluded . Can you please help me ? I tried substring and lastIndexOf but this seems useful when you have fixed length,i donot have fixed length input . It can be of any length. if anyone can please suggest some java code it will be great. textractdelimitedfield would not help in my scenario.Only tmap or javacode would .

Labels (5)
1 Solution

Accepted Solutions
d_o
Contributor
Contributor

Along the same lines as what Ansel suggested, assuming your string was in Notes, you might try the following:

 

StringHandling.RIGHT(row10.Notes,((int)StringHandling.LEN(row10.Notes))-((int)row10.Notes.indexOf(":"))-1)

View solution in original post

6 Replies
kakooo16
Creator
Creator

You can use a tNormalize component and put ":" as your delimiteur

RP1629548713
Contributor II
Contributor II
Author

No ,I have already tried it ,doesnt help. I would rather require a regex or a routine

anselmopeixoto
Partner - Creator III
Partner - Creator III

Hello @Riya P​ 

 

Supposing this String is in a column called "content" coming from a input called row1, what if you try the following:

 

row1.content.substring(row1.content.indexOf(":"))

 

The indexOf method returns the index of the first occurrence of ":" inside the source String and passes this index to the substring method, which you get all the String content after ":"

 

You can add +1 to this index to exclude the ":" from the result:

 

row1.content.substring(row1.content.indexOf(":")+1)

RP1629548713
Contributor II
Contributor II
Author

Hey hi, thanks for suggesting this way. I tried it but it's storing the 1st part of the string whereas I'm in need of the later

d_o
Contributor
Contributor

Along the same lines as what Ansel suggested, assuming your string was in Notes, you might try the following:

 

StringHandling.RIGHT(row10.Notes,((int)StringHandling.LEN(row10.Notes))-((int)row10.Notes.indexOf(":"))-1)

RP1629548713
Contributor II
Contributor II
Author

Works 🙂 Thanks !