title: Splitting by html elements in Javascript
body: <p>I have a bunch of strings that typically looks something like this:</p>
  <pre class="lang-html prettyprint-override"><code>string 1&lt;div&gt;string 2&lt;br&gt;&lt;/div&gt;string 3
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>string 1&lt;div&gt;string 2&lt;br&gt;&lt;/div&gt;&lt;div&gt;string 3&lt;br&gt;&lt;/div&gt;
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;div&gt;string 1&lt;br&gt;&lt;/div&gt;&lt;div&gt;string 2&lt;br&gt;&lt;/div&gt;&lt;div&gt;string 3&lt;br&gt;&lt;/div&gt;
  </code></pre>
  <p>And I need to extract the text (both inside and outside/between elements, as seen above) into an array like this:</p>
  <pre><code>['string 1', 'string 2', 'string 3']
  </code></pre>
  <p>Is there a way to do this in pure Javascript?</p>
  <p>I tried something like this:</p>
  <pre class="lang-js prettyprint-override"><code>console.log(text.split(/&lt;div&gt;(.*)&lt;br&gt;&lt;\/div&gt;/g))
  </code></pre>
  <p>But it only works for the first one:</p>
  <pre class="lang-js prettyprint-override"><code>[ 'string 1', 'string 2', 'string 3' ]
  </code></pre>
  <p>While it fails on the two last variations:</p>
  <pre class="lang-js prettyprint-override"><code>[ 'string 1', 'string 2&lt;br&gt;&lt;/div&gt;&lt;div&gt;string 3', '' ]
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>[ '', 'string 1&lt;br&gt;&lt;/div&gt;&lt;div&gt;string 2&lt;br&gt;&lt;/div&gt;&lt;div&gt;string 3', '' ]
  </code></pre>