title: Select the first paragraph tag not contained in within another tag using RegEx (Perl-style)
body: <p>I have this block of html:</p>
  
  <pre><code>&lt;div&gt;
    &lt;p&gt;First, nested paragraph&lt;/p&gt;
  &lt;/div&gt;
  &lt;p&gt;First, non-nested paragraph.&lt;/p&gt;
  &lt;p&gt;Second paragraph.&lt;/p&gt;
  &lt;p&gt;Last paragraph.&lt;/p&gt;
  </code></pre>
  
  <p>I'm trying to select the <strong>first, non-nested paragraph</strong> in that block. I'm using PHP's (perl style) preg_match to find it, but can't seem to figure out how to ignore the p tag contained within the div.</p>
  
  <p>This is what I have so far, but it selects the contents of the first paragraph contained above.</p>
  
  <pre><code>/&lt;p&gt;(.+?)&lt;\/p&gt;/is
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Unfortunately, I don't have the luxury of a DOM Parser.</p>
  
  <p>I completely appreciate the suggestions to not use RegEx to parse HTML, but that's not really helping my particular use case. I have a very controlled case where an internal application generated structured text. I'm trying to replace some text if it matches a certain pattern. This is a simplified case where I'm trying to ignore text nested within other text and HTML was the simplest case I could think of to explain. My actual case looks something a little more like this (But a lot more data and minified):</p>
  
  <pre><code>#[BILLINGCODE|12345|11|15|2001|15|26|50]#
  [ITEM1|{{Escaped Description}}|1|1|4031|NONE|15]
  #[{{Additional Details }}]#
  [ITEM2|{{Escaped Description}}|3|1|7331|NONE|15]
  [ITEM3|{{Escaped Description}}|1|1|9431|NONE|15]
  [ITEM4|{{Escaped Description}}|1|1|5131|NONE|15]
  </code></pre>
  
  <p>I have to reformat a certain column of certain rows to a ton of rows similar to that. Helping my first question would help actual project.</p>