title: How to split a string to identical parts without a giving pattern?
body: <p>I have a function that returns every time a different string but with a specific random pattern, this pattern could be as simple as "a, b, c, <strong>a, b, c</strong>" or something much more complicated.</p>
  
  <p>So what I need is to write a function that searches in the string for a pattern and return it.</p>
  
  <p>There is only one condition to be considered, let's say we have this string for example: "a, b, a, b, c, a, b, a, b, c"</p>
  
  <p>In that string you can't say that "a, b" is a pattern, to consider a specific string as a pattern then it should be longer than the remaining string, in that case, "a,b" is (2 digits * 2) = 4 and the remaining is "c, a, b, a, b, c" 6 digits, so what consider a real pattern is "a, b, a, b, c".</p>
  
  <p>I was about writing a function to do that but I know it's going to be a complicated one so I thought to ask SO before if maybe there is a built-in functionality in PHP or Javascript which can do something close from that or makes the job easier for me, so any ideas guys?</p>