Suppose I had a string, "cats cats cats and dogs dogs dogs."
What regular expression would I use in order to replace that string with,"cats and dogs." i.e. removing duplicates. The expression however must only remove duplicates that follow after each other. For instance:
"cats cats cats and dogs dogs dogs and cats cats and dogs dogs"
Would return:
"cats and dogs and cats and dogs"