Regex for replacing <p> tags with line breaks
I have the following HTML
<p>Some text <a title="link" href="http://link.com/" target="_blank">my link</a> more
text <a title="link" href="http://link.com/" target="_blank">more link</a>.</p>
<p>Another paragraph.</p>
<p>[code:cf]</p>
<p><cfset ArrFruits = ["Orange", "Apple", "Peach", "Blueberry", </p>
<p>"Blackberry", "Strawberry", "Grape", "Mango", </p>
<p>"Clementine", "Cherry", "Plum", "Guava", </p>
<p>"Cranberry"]></p>
<p>[/code]</p>
<p>Another line</p>
<p><img src="http://image.jpg" alt="Array" />
</p>
<p>More text</p>
<p>[code:cf]</p>
<p><table border="1"></p>
<p> <cfoutput></p>
<p> <cfloop array="#GroupsOf(ArrFruits, 5)#" index="arrFruitsIX"></p>
<p> <tr></p>
<p> <cfloop array="#arrFruitsIX#" index="arrFruit"></p>
<p> <td>#arrFruit#</td></p>
<p> </cfloop></p>
<p> </tr></p>
<p> </cfloop></p>
<p> </cfoutput></p>
<p></table></p>
<p>[/code]</p>
<p>With an output that looks like:</p>
<p><img src="another_image.jpg" alt="" width="342" height="85" /></p>
What I'm trying to do is write a regular expression that will delete everything <p>or </p>, and whenever it finds it </p>, it will replace it with a line break.
So far, my template has looked like this:
/\<p\>(.*?)(<\/p>)/g
And I will replace the matches:
$1\n
Everything looks good, but it also replaces the content inside the tags [code][/code], which in this case should not replace the tags at all <p>, so as a result I could get rid of <p>it when the content is not inside the tags [code].
I can never get denial, I know that it will be something like
\<p\>^\[code*\](.*?)(<\/p>)
But obviously this does not work :-)
Can someone help me with this regex?
, , HTML. , , , .