title: Replace repeating strings in a string
body: <p>I'm trying to find (and replace) repeated string in a string.</p>
  
  <p>My string can look like this:</p>
  
  <blockquote>
    <p>Lorem ipsum dolor sit <strong>amet sit amet sit amet sit</strong> nostrud exercitation <em>amit sit</em> ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
  </blockquote>
  
  <p>This should become:</p>
  
  <blockquote>
    <p>Lorem ipsum dolor sit <strong>amet sit</strong> nostrud exercitation <em>amit sit</em> ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
  </blockquote>
  
  <p>Note how the <em>amit sit</em> isn't removed since its not repeated.</p>
  
  <p>Or the string can be like this:</p>
  
  <blockquote>
    <p>Lorem ipsum dolor sit <strong>amet () sit amet () sit amet () sit</strong> nostrud exercitation ullamco laboris nisi ut <strong>aliquip aliquip</strong> ex ea commodo consequat.</p>
  </blockquote>
  
  <p>which should become:</p>
  
  <blockquote>
    <p>Lorem ipsum dolor sit <strong>amet () sit</strong> nostrud exercitation ullamco laboris nisi ut <strong>aliquip</strong> ex ea commodo consequat.</p>
  </blockquote>
  
  <p>So its not just a-z but can also have other (ascii) chars. I'm verry happy if someone can help me with this.</p>
  
  <p>The next step would be to match (and replace) something like this:</p>
  
  <blockquote>
    <p>2 questions 3 questions 4 questions 5 questions</p>
  </blockquote>
  
  <p>which would become:</p>
  
  <blockquote>
    <p>2 questions</p>
  </blockquote>
  
  <p>The number in the final output can be any number 2,3,4, it doesn't matter. There will only be different numbers in the final example but the words will be the same.</p>