title: Using Regex to split XML string before and after match
body: <p>I'm trying to format a XML document, so I pass a string into a method, such as:</p>
  
  <pre><code>"&lt;foo&gt;&lt;subfoo&gt;&lt;subsubfoo&gt;content&lt;/subsubfoo&gt;&lt;/subfoo&gt;&lt;subfoo/&gt;&lt;/foo&gt;"
  </code></pre>
  
  <p>And I'm trying to split it based on finding the tags. I want to split each element (a tag, or content) into a unique string, such as:</p>
  
  <pre><code>"&lt;foo&gt;", "&lt;subfoo&gt;", "&lt;subsubfoo&gt;", "content", "&lt;/subsubfoo&gt;", "&lt;/subfoo&gt;", "&lt;subfoo/&gt;", "&lt;/foo&gt;"
  </code></pre>
  
  <p>And to this end I use the code:</p>
  
  <pre><code>string findTagString = "(?&lt;=&lt;.*?&gt;)";
  Regex findTag = new Regex(findTagString);
  List&lt;string&gt; textList = findTag.Split(text).ToList();
  </code></pre>
  
  <p>The above code works fine, except it doesn't split "content" into its own string, instead:</p>
  
  <pre><code>"&lt;foo&gt;", "&lt;subfoo&gt;", "&lt;subsubfoo&gt;", "content&lt;/subsubfoo&gt;", "&lt;/subfoo&gt;", "&lt;subfoo/&gt;", "&lt;/foo&gt;"
  </code></pre>
  
  <p>Is there a way to rewrite the Regex to acomplish this, the splitting of non-matches into their own string?</p>
  
  <p>Or, rephrased: Is it possible to split a string before AND after a Regex match?</p>