If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Parse string at last delimiter from the right

Started by Cogency, 20 May 2025 10:59:50 PM

Previous topic - Next topic

Cogency

Hi all,

I have a string column with varying lengths of text and varying numbers of spaces.  I'd like to isolate the text following the last space at the end of the string.  Any ideas about how I can do that?

Thanks,

Cogency

Cogency

e.g. If the text read 'AAAA 12345 BBBB CCCC' I'd like to create a column that shows 'CCCC'.

Cogency

I've found a 3-step solution

1.   Reverse = reverse([String_Column])
2.   ParseReverse = substring([Reverse], 1, position(' ', [Reverse])-1)
3.   ReverseParseReverse = reverse([ParseReverse])

It's a bit long-winded but it works.

Andrei I

You can use regular expressions:

substring_regex ('\b\w+\W*$', [String_Column])