title: Merging a set of characters if the next row of characters has the same set?
body: <p>Let's say I have the following string.</p>
  
  <pre><code>&amp;eThe quick brown fox &amp;djumps over the &amp;dlazy &amp;adog.
  </code></pre>
  
  <p>Each set of color codes <code>&amp;letter</code>, e.g <code>&amp;e</code> will change the color of the following text until another color code appears. It's redundant to have two of the same codes follow after each other because it's both the same color.</p>
  
  <pre><code>&amp;djumps over the &amp;dlazy
  </code></pre>
  
  <p>I'm trying to merge any duplicate color code that matches the color code before it, so the above string would change into the following:</p>
  
  <pre><code>&amp;eThe quick brown fox &amp;djumps over the lazy &amp;adog.
  </code></pre>
  
  <p>However I'm not sure how this is done. Can anyone help?</p>