Anyone know how to write an expression to remove the second instance of repeated words where they exist in a string?
Suppose string1 = "It's going to rain in 10mins in London London". I want string2 = "It's going to rain in 10mins in London"
Removing repeated words in a string
Moderator: Martin
Re: Removing repeated words in a string
Check out this page:
https://stackoverflow.com/questions/282 ... cate-words
Something like this should work:
Regards,
Martin
https://stackoverflow.com/questions/282 ... cate-words
Something like this should work:
Code: Select all
string2 = replaceAll(string1, '(\\b\\S+\\b)\\s+\\b\\1\\b', '$1');
Martin
Re: Removing repeated words in a string
Thanks for the steer Martin