title: Split html string by tags without losing split character
body: <p>How do I split a string like </p>
  
  <pre><code>var htmlstring = "&lt;html&gt;&lt;body&gt;&lt;div&gt;&lt;p&gt;this is &lt;span&gt; example &lt;/span&gt;text&lt;/p&gt;&lt;/div&gt;&lt;/body&gt; &lt;/html&gt;"
  var output=htmlstring.split(solution);
  
  // output should be 
  
  [ "&lt;html&gt;&lt;body&gt;&lt;div&gt;&lt;p&gt;", "this is", "&lt;span&gt;", "example", "&lt;/span&gt;", "text", "&lt;/p&gt;&lt;/div&gt;&lt;/body&gt; &lt;/html&gt;"]
  </code></pre>
  
  <p>The solution should work for any string of html no matter how long or complicated it is </p>
  
  <p>Solution does not have to be regex that is just what I have used so far </p>
  
  <p>Any function that is better is fine as well</p>
  
  <p>I know match() can be used</p>
  
  <p>Have found regex to separate without losing seperator using dummy variable in replace function but does not separate the plain text into separate indexes </p>
  
  <p>I have it now in separated by tags and text </p>