Clear a duplicate word in a string

Hello,
What’s the easiest way to delete a duplicate word in a string? Does it exist a simple function for this?

As an instance, I’ve got the following string of characters :
______ ___ banana ___ _________ __ banana

I want to clear the second “banana”

Do you know what the words are ahead of time or do you went to remove any 2nd appearance of any word?

remove any 2nd appearance of any word

I came up with this:

{{join(distinct(split("apple banana orange apple grape banana orange apple apple melon orange apple grape banana orange pineapple"; space)); space)}}

It assumes no punctuation though. So apple and apple. would be treated separately.

You could strip out all periods first by replacing them with spaces (if you don’t mind losing punctuation), or first split your string into distinct sentences ({{split("string"; ".")}}) and then run them each through the above function. You could then add a period to the end of each output string and reassemble your string.

2 Likes