title: Regex to remove repeated character pattern in a string
body: <p>I have a string that may have a repeated character pattern, e.g.</p>
  
  <pre><code>'xyzzyxxyzzyxxyzzyx'
  </code></pre>
  
  <p>I need to write a regex that would replace such string with its smallest repeated pattern:</p>
  
  <pre><code>'xyzzyxxyzzyxxyzzyx' becomes 'xyzzyx',
  
  'abcbaccbaabcbaccbaabcbaccba' becomes 'abcbaccba'
  </code></pre>