Split after last space

Hi

I have a field looking like this
xxxx feeee ddd fff
ddd fff eee kkkkk ss
ddd sss xx
I would like to find the last space and then split the last
So I want to see
fff
ss
xx
I do know that I can split all, but the size of the fields differs.

Any suggestions on:
Find last space and then split it after last space.

Thanks

Hi Rykie,

you can use the mirror() function to reverse text, keep characters before the 1st space using keepbefore(), then reverse back using mirror() again.

See example below:
keep after last space.morph (1.7 KB)

1 Like

Excellent!!

Thank you Dmitry.

UPDATE

We’ve added the optional third argument to functions keepafter() and keepbefore(). The argument allows specifying the number of delimiters after/before which to keep text. The number can be negative. In this case, it counts from the end. So it’s no longer necessary to use the mirror() function.

Example

keepafter("xxxx feeee ddd fff", " ", -1) //returns "fff"
keepbefore("xxxx feeee ddd fff", " ", 2) //returns "xxxx feeee"
2 Likes

Thanks, Dmitry. I started to use it today!
R