Originally Posted by Wims
Simo's code doesn't work correctly, your example is also incorrect as it doesn't contain the same word twice. Here is something that works, it deletes from the left:

//echo -a $regsubex(Nickname1 Nickname1 Nickname2 Nickname3 Nickname2 Nickname1,/(?:\G| )([^ ]+) (?=(?:\1|.* \1)(?: |$))/gSi,)
Quote
Nickname3 Nickname2 Nickname1

Hi @Wims

While deleting the second repetition, it merges it with the other value. See;

//echo -a $regsubex(Nickname1 Nickname3 NickName2 Nickname2 Nickname1,/(?:\G| )([^ ]+) (?=(?:\1|.* \1)(?: |$))/gSi,)


Return: Nickname3Nickname2 Nickname1