title: Tokenize HTML string in JavaScript
body: <p>I would like to split a string that looks like:</p>
  
  <pre><code>This is &lt;strong&gt;a&lt;/strong&gt; test &lt;a href="#test"&gt;link&lt;/a&gt; and &lt;br /&gt; line. break
  </code></pre>
  
  <p>into the following with JavaScript:</p>
  
  <pre><code>[
      'This',
      'is',
      '&lt;strong&gt;a&lt;/strong&gt;',
      'test',
      '&lt;a href="#test"&gt;link&lt;/a&gt;',
      '&lt;br /&gt;',
      'line.',
  ]
  </code></pre>
  
  <p>I tried splitting on spaces, and <code>&lt;</code> <code>&gt;</code>, but that obviously doesn't work for tags like <code>strong</code> and <code>a</code>. I'm not sure how to write a regex that doesn't split within HTML tags. I also tried to use jQuery <code>children()</code>, but it doesn't extract plain text, just the html tags. Any help would be great.</p>