Replacing/deleting string

Hallo, I’ve got a strings like this:
Rejestr zakupów z przelewem SUMA
Rejestr zakupów odliczenie SUMA.
There is different count of spaces before this last word. The last Word is always the same. Can anybody tell me how to delete this spaces in the end and the last word.

You can use function trim([string]).LastIndexOf(" ") to get the position index (let s assign this value as i) of the last space before the last word.

Then you can use LEFT(trim([string]), i) to get the string without the last space & last word.

@qlka08

Do you want to delete the spaces at the end of this String and also that word SUMA right ?

If yes then try below one and as you said last word SUMA is always same only.

Str = “Rejestr zakupów odliczenie SUMA”

Str.Replace(“SUMA”,"").TrimEnd

@lakshman
Thank you for your help it was great solution.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.