title: Regular Expression to replace <p> tags with line breaks
body: <p>I have the following HTML</p>
  
  <pre><code>&lt;p&gt;Some text &lt;a title="link" href="http://link.com/" target="_blank"&gt;my link&lt;/a&gt; more 
  text &lt;a title="link" href="http://link.com/" target="_blank"&gt;more link&lt;/a&gt;.&lt;/p&gt;
  &lt;p&gt;Another paragraph.&lt;/p&gt;
  &lt;p&gt;[code:cf]&lt;/p&gt;
  &lt;p&gt;&amp;lt;cfset ArrFruits = ["Orange", "Apple", "Peach", "Blueberry", &lt;/p&gt;
  &lt;p&gt;"Blackberry", "Strawberry", "Grape", "Mango", &lt;/p&gt;
  &lt;p&gt;"Clementine", "Cherry", "Plum", "Guava", &lt;/p&gt;
  &lt;p&gt;"Cranberry"]&amp;gt;&lt;/p&gt;
  &lt;p&gt;[/code]&lt;/p&gt;
  &lt;p&gt;Another line&lt;/p&gt;
  &lt;p&gt;&lt;img src="http://image.jpg" alt="Array" /&gt;
  &lt;/p&gt;
  &lt;p&gt;More text&lt;/p&gt;
  &lt;p&gt;[code:cf]&lt;/p&gt;
  &lt;p&gt;&amp;lt;table border="1"&amp;gt;&lt;/p&gt;
  &lt;p&gt; &amp;lt;cfoutput&amp;gt;&lt;/p&gt;
  &lt;p&gt; &amp;lt;cfloop array="#GroupsOf(ArrFruits, 5)#" index="arrFruitsIX"&amp;gt;&lt;/p&gt;
  &lt;p&gt;  &amp;lt;tr&amp;gt;&lt;/p&gt;
  &lt;p&gt; &amp;lt;cfloop array="#arrFruitsIX#" index="arrFruit"&amp;gt;&lt;/p&gt;
  &lt;p&gt;     &amp;lt;td&amp;gt;#arrFruit#&amp;lt;/td&amp;gt;&lt;/p&gt;
  &lt;p&gt; &amp;lt;/cfloop&amp;gt;&lt;/p&gt;
  &lt;p&gt;  &amp;lt;/tr&amp;gt;&lt;/p&gt;
  &lt;p&gt; &amp;lt;/cfloop&amp;gt;&lt;/p&gt;
  &lt;p&gt; &amp;lt;/cfoutput&amp;gt;&lt;/p&gt;
  &lt;p&gt;&amp;lt;/table&amp;gt;&lt;/p&gt;
  &lt;p&gt;[/code]&lt;/p&gt;
  &lt;p&gt;With an output that looks like:&lt;/p&gt;
  &lt;p&gt;&lt;img src="another_image.jpg" alt="" width="342" height="85" /&gt;&lt;/p&gt;
  </code></pre>
  
  <p>What I'm trying to do, is write a regular expression that will remove all the <code>&lt;p&gt;</code> or <code>&lt;/p&gt;</code>, and whenever it finds a <code>&lt;/p&gt;</code>, it will replace it with a line-break.</p>
  
  <p>So far, my pattern looks like this:</p>
  
  <pre><code>/\&lt;p\&gt;(.*?)(&lt;\/p&gt;)/g
  </code></pre>
  
  <p>And I'm replacing the matches with:</p>
  
  <pre><code>$1\n
  </code></pre>
  
  <p>It all looks good, but it's also replacing the contents inside the <code>[code][/code]</code> tags, which in this case should not replace the <code>&lt;p&gt;</code> tags at all, so as a result, i would lkike to get rid of the <code>&lt;p&gt;</code> tags, when the content <strong>isn't</strong> inside the <code>[code]</code> tags.</p>
  
  <p>I can't ever get negation right, I know it will be something along the lines of</p>
  
  <pre><code>\&lt;p\&gt;^\[code*\](.*?)(&lt;\/p&gt;)
  </code></pre>
  
  <p>But obviously this doesn't work :-)</p>
  
  <p>Could anyone please lend me a hand with this regex?</p>
  
  <p><strong>BTW, I know I shouldn't be using regular expressions to parse HTML at all. I'm fully aware of that, but still, for this specific case, I'd like to use regex.</strong></p>
  
  <p>Thanks in advance</p>