title: Split a string of HTML into an array by particular tags
body: <p>Given this HTML as a string "html", how can I split it into an array where each header <code>&lt;h</code> marks the start of an element?</p>
  
  <p><strong>Begin with this:</strong></p>
  
  <pre><code>&lt;h1&gt;A&lt;/h1&gt;
  &lt;h2&gt;B&lt;/h2&gt;
  &lt;p&gt;Foobar&lt;/p&gt;
  &lt;h3&gt;C&lt;/h3&gt;
  </code></pre>
  
  <p><strong>Result</strong>: </p>
  
  <pre><code>["&lt;h1&gt;A&lt;/h1&gt;", "&lt;h2&gt;B&lt;/h2&gt;&lt;p&gt;Foobar&lt;/p&gt;", "&lt;h3&gt;C&lt;/h3&gt;"]
  </code></pre>
  
  <p><strong>What I've tried:</strong></p>
  
  <p>I wanted to use <code>Array.split()</code> with a regex, but the result splits each <code>&lt;h</code> into its own element. I need to figure out how to capture from the start of one <code>&lt;h</code> until the next <code>&lt;h</code>. Then include the first one but exclude the second one.</p>
  
  <pre><code>var html = '&lt;h1&gt;A&lt;/h1&gt;&lt;h2&gt;B&lt;/h2&gt;&lt;p&gt;Foobar&lt;/p&gt;&lt;h3&gt;C&lt;/h3&gt;';
  var foo = html.split(/(&lt;h)/);
  </code></pre>
  
  <p><strong>Edit</strong>: Regex is not a requirement in anyway, it's just the only solution that I thought would work for generally splitting HTML strings in this way.</p>