title: Splitting a string of numbers with different digit sizes in Ruby
body: <p>I'm trying to figure out if there's a way to split a string that contains numbers with different digit sizes without having to use if/else statements. Is there an outright method for doing so. Here is an example string: </p>
  
  <pre><code>"123456789101112131415161718192021222324252627282930"
  </code></pre>
  
  <p>So that it would be split into an array containing 1-9 and 10-30 without having to first split the array into single digits, separate it, find the 9, and iterate through combining every 2 elements after the 9.</p>
  
  <p>Here is the current way I would go about doing this to clarify:</p>
  
  <pre><code>single_digits, double_digits = [], []
  string = "123456789101112131415161718192021222324252627282930".split('')
  
  single_digits &lt;&lt; string.slice!(0,9)
  single_digits.map! {|e| e.to_i}
  string.each_slice(2) {|num| double_digits &lt;&lt; num.join.to_i}
  </code></pre>
  
  <p>This would give me:</p>
  
  <pre><code>single_digits = [1,2,3,4,5,6,7,8,9]
  double_digits = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
  </code></pre>