title: How to split string using regex without consuming the splitter part?
body: <p>How would I split a string without consuming the splitter part?<br />
  Something like this but instead <code>:</code> I'm using <code>#[a-fA-F0-9]{6}</code> regex.
  <br></p>
  <pre><code>String from = &quot;one:two:three&quot;;
  String[] to  = [&quot;one&quot;,&quot;:&quot;,&quot;two&quot;,&quot;:&quot;,&quot;three&quot;];
  </code></pre>
  <p>I already tried using commons lib since it has <code>StringUtils.splitPreserveAllTokens()</code> but it does not work with regex.</p>
  <p>EDIT: I guess I should have been more specific, but this is more of what I was looking for.</p>
  <pre><code>String string = &quot;Some text here #58a337test #a5fadbtest #123456test as well.
   #58a337Word#a5fadbwith#123456more hex codes.&quot;;
  
  String[] parts = string.split(&quot;#[a-fA-F0-9]{6}&quot;);
  /*Output: [&quot;Some text here &quot;,&quot;#58a337&quot;,&quot;test &quot;,&quot;#a5fadb&quot;,&quot;test &quot;,&quot;#123456&quot;,&quot;test as well. &quot;,
  &quot;#58a337&quot;,&quot;Word&quot;,&quot;#a5fadb&quot;,&quot;with&quot;,&quot;#123456&quot;,&quot;more hex codes.&quot;]*/
  </code></pre>
  <p>EDIT 2: Solution!</p>
  <pre><code>final String string = &quot;Some text here #58a337test #a5fadbtest #123456test as
   well. #58a337Word#a5fadbwith#123456more hex codes.&quot;;
  
  String[] parts = string.split(&quot;(?=#.{6})|(?&lt;=#.{6})&quot;);
  for(String s: parts) {
      System.out.println(s);
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>Some text here 
  #58a337
  test 
  #a5fadb
  test 
  #123456
  test as well. 
  #58a337
  Word
  #a5fadb
  with
  #123456
  more hex codes.
  </code></pre>