title: Ruby : Split string on boundaries
body: <p>I have a string of arbitrary characters, some of which are digits. I would like to break the strings into fields consisting of digits and non-digits. For example, if my string has the value 'abc34d-f9', I would like to get an array </p>
  
  <pre><code>['abc','34','d-f','9']
  </code></pre>
  
  <p>I'm nearly there, using look-behind and look-ahead expressions:</p>
  
  <pre><code>s.split(/( (?&lt;=\D)(?=\d) | (?&lt;=\d)(?=\D) )/x)
  </code></pre>
  
  <p>This splits on transitions between boundaries digit->nondigit and vice versa. However, I also get empty elements, i.e. this would return</p>
  
  <pre><code>['abc','','34','','d-f','','9']
  </code></pre>
  
  <p>Of course it is trivial to filter out the nullstrings from the array. I just wonder: Why do I get them, and how can I do it better?</p>