strip outerHTML from html string

strip outerHTML from html string

Hi,

Considering I have a HTML string like this:

  1. <span><span><div>this text</div></span></span>
I want to get the left side of the outerHTML as a string as well as the right side:

  1. var leftSide= <span><span><div>;
  2. var rightSide= </div></span></span>;
Is there a way to do this? 

Regards.