title: Split an array by a repetitive value
body: <p>I have a variable length array of arbitrary strings. The one consistency is the string "hello" is repeated and I want to partition the array in groups by the string "hello".</p>
  
  <p>So given this:</p>
  
  <pre><code>[
   "hello\r\n",
   "I\r\n",
   "am\r\n",
   "Bob\r\n",
   "hello\r\n",
   "How\r\n",
   "are you?\r\n"
  ]
  </code></pre>
  
  <p>I want this:</p>
  
  <pre><code>[
   [
     "hello\r\n",
     "I\r\n",
     "am\r\n",
     "Bob\r\n"
   ],
   [
     "hello\r\n",
     "How\r\n",
     "are you?\r\n"
   ]
  ]
  </code></pre>
  
  <p>What I have tried:</p>
  
  <pre><code>partition = []
  last = input.size
  index = 0
  input.each_with_object([]) do |line, acc|
     index += 1
    if line == "hello\r\n"
      acc &lt;&lt; partition
      partition = []
      partition &lt;&lt; line
    else
      partition &lt;&lt; line  
    end
    if index == last
      acc &lt;&lt; partition
    end
    acc
  end.delete_if(&amp;:blank?)
  =&gt; [["hello\r\n", "I\r\n", "am\r\n", "Bob\r\n"], ["hello\r\n", "How\r\n", "are you?\r\n"]] 
  </code></pre>
  
  <p>The result is right, but is it possible to do what I want with ruby array iterators? My solution seems clunky.</p>