title: Perl 6: Lookahead with capture
body: <p>I'm attempting to write a Perl 6 regex for <a href="https://codegolf.stackexchange.com/q/189859/76162">this code-golf challenge</a> that splits a string with the rules:</p>
  
  <ul>
  <li>Sequences of the same character with length 3 or less will be grouped together</li>
  <li>But 4 or more will result in the first two being grouped before checking the rest</li>
  </ul>
  
  <p>For example:</p>
  
  <pre><code>66667888    -&gt; '66', '66, '7', '888'
  19999999179 -&gt; '1', '99', '99', '999', '1', '7', '9'
  </code></pre>
  
  <p>I thought the regex <code>m:g/(.)[$0$0&lt;!$0&gt;|$0?]/</code> would work, but using a capture in the negative lookahead seems to break it, and I can't figure out how to use it properly. </p>
  
  <p>Depending on how I use it, it either <a href="https://tio.run/##K0gtyjH7/784sVKhOtcqXV9DTzNaxUDFwEZRxcCuRsXAPla/VkPJ0BICDM0tlTT//wcA" rel="noreferrer">loops forever</a>, throws the <a href="https://tio.run/##K0gtyjH7/784sVKhOtcqXV9DTzNaxUDFwEZRxcCuRsXAPla/VkPJEgIMzS2VNP//BwA" rel="noreferrer">error</a> <code>Cannot resolve caller INTERPOLATE_ASSERTION</code>, or <a href="https://tio.run/##K0gtyjH7/784sVJBydASAgzNLZUU6uoUcq3S9TX0NKNVDFQMbBRVDOxqVAzsY/X//wcA" rel="noreferrer">returns the wrong result</a>. Is there a proper way to use captures in lookaheads, or is this a bug?</p>