title: Ruby Split string at character difference using regex
body: <p>I'm current working on a problem that involves splitting a string by each group of characters.</p>
  
  <p>For example,</p>
  
  <pre><code>"111223334456777" #=&gt; ['111','22','333','44','5','6','777']
  </code></pre>
  
  <p>The way I am currently doing it now is using a enumerator and comparing each character with the next one, and splitting the array that way. </p>
  
  <pre><code>res = []
  str = "111223334456777"
  group = str[0]
  (1...str.length).each do |i|
    if str[i] != str[i-1]
      res &lt;&lt; group
      group = str[i]
    else
      group &lt;&lt; str[i]
    end
  end
  res &lt;&lt; group
  res #=&gt; ['111','22','333','44','5','6','777']
  </code></pre>
  
  <p>I want to see if I can use regex to do this, which will make this process a lot easier. I understand I could just put this block of code in a method, but I'm curious if regex can be used here. </p>
  
  <p>So what I want to do is </p>
  
  <pre><code>str.split(/some regex/)
  </code></pre>
  
  <p>to produce the same result. I thought about positive lookahead, but I can't figure out how to have regex recognize that the character is different. </p>
  
  <p>Does anyone have an idea if this is possible?</p>