title: How to parse only the first level of nested tags with regex?
body: <p>Say I have a block of text like this:</p>
  
  <pre><code>&lt;item&gt;
     foo bar foo bar 
     &lt;item&gt; child item &lt;/item&gt;
  &lt;/item&gt;
  &lt;item&gt;
     second item
     &lt;item&gt; second child &lt;/item&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>Here, what I want is to parse only the two top levels of <code>&lt;item&gt;</code>s to be parsed, and the result returned to me in an array like this:</p>
  
  <pre><code>[0] = "foo bar foo bar  &lt;item&gt;child item&lt;/item&gt;"
  [1] = "second item  &lt;item&gt;second child &lt;/item&gt;";
  </code></pre>
  
  <p>However in my testing, since the child level <code>&lt;item&gt;</code> tags match the pattern, they are also included and I get a 4 element array rather than a 2 element array as I want.</p>
  
  <p>This is the pattern I've used:</p>
  
  <pre><code>%&lt;item&gt;(.+)&lt;/item&gt;%si
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>Edit: This is NOT for HTML, its for a custom, in-house scripting language for which I can't use any dom parsers. So please suggest a regex solution.</strong></p>