title: Perl regular expression removing duplicate consecutive substrings in a string
body: <p>I tried to do a search on this particular problem, but all I get is either removal of duplicate lines or removal of repeated strings where they are separated by a delimiter.</p>
  
  <p>My problem is slightly different. I have a string such as </p>
  
  <pre><code>    "comp name1 comp name2 comp name2 comp name3" 
  </code></pre>
  
  <p>where I want to remove the repeated comp name2 and return only </p>
  
  <pre><code>    "comp name1 comp name2 comp name3" 
  </code></pre>
  
  <p>They are not consecutive duplicate words, but consecutive duplicate substrings. Is there a way to solve this using regular expressions?</p>