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: 
Anonymous
Not applicable

Removing characters before second occurence of space using tMap

Hi Anyone,
 
I just wanted to ask if how could I remove all the characters before the second occurrence of space in a string using tMap?

For example:
Input: "This is a sentence"
Ouput: "a sentence"
Thanks!

Labels (2)
4 Replies
TRF
Champion II
Champion II

Hi,

Maybe not the better way but should work:

row1.sentence.replaceAll("^.* ", "").replaceAll("^.* ", "")

Regards,
TRF
Anonymous
Not applicable
Author

You may write routine which can return the position and use the same in the substring method to get the desired output.
or alternatively by overloading the indexof method and use expression like this : row1.Input.indexOf(" ", row1.Input.indexOf(" ")+1) to get the index position of the 2nd space and use the value in substring to get the desired string: row1.Input.substring(Var.var1+1) 
Also for a generic solution of index location look up ordinalIndexOf method in  here
Anonymous
Not applicable
Author

Hi TRF,
Thank you for your reply. Sorry for not responding right away. I've been experiencing connectivity issues.
Hi rana.abhimanyu90,
Thank you for helping me again, let me try to use your approach. Thanks!
Anonymous
Not applicable
Author

Hi rana.abhimanyu90,
This helped resolve my issue. Also, thank you for the additional info. Thanks!