Say I have a line, for example:
where is mummy where is daddy
I want to replace any set of repetitive substrings blank lines - so in this case, the elements whereand iswill be removed, and the resulting string will be:
mummy daddy
I was wondering if there was any one regular expression that could achieve this. The regular expression I tried (which doesn't work) is as follows:
/(\w+)(?=.*)\1/gi
If the first capture group is any set of word characters, the second is a positive look at any set of characters (to prevent the inclusion of these characters in the result), and then it \1is a backward link to the first subscript.
Any help would be great. Thanks in advance!