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: 
stephbzr
Contributor III

Extract the string after the first space

Hello,

I can't find a java method that allows me to extract the whole string after the first space. For example, I have strings : 

- word1 word2 word3

or 

- word1 word 2 

I want to have 

- word2 word3

or 

- word2

Thank you

Labels (4)
1 Solution

Accepted Solutions
stephbzr
Contributor III
Author

I finally used your solution with tMap because I'm not sure if it works with tWarn. Thanks

 

0695b00000bEDhxAAG.png0695b00000bEE1nAAG.png

View solution in original post

4 Replies
Anonymous
Not applicable

try this

row1.name.contains(" ")?row1.name.substring(row1.indexOf(" ")+1):""

 

// this expression is used to check if the string contains blank space? if yes, extract the whole string after the first space, if no, return an empty string.

 

Regards

Shong

stephbzr
Contributor III
Author

Thanks for the help @Shicong Hong​, it will be useful if I encounter this case in a tMap.

But I forgot to mention that I am looking to do this in a tWarn! In the context of a joblet, I use a context variable where the first word is always the same, but depending on the job, the second word varies. 

 

I tried that, but without success

 

0695b00000bEDSoAAO.png

stephbzr
Contributor III
Author

I finally used your solution with tMap because I'm not sure if it works with tWarn. Thanks

 

0695b00000bEDhxAAG.png0695b00000bEE1nAAG.png

jlolling
Creator III

I would use regex expressions to do that. There is a component tExtractRegexFields to handle regex.