title: PHP Remove all paragraph tags inside header tags
body: <p>I've been dwelling on this for a while.</p>
  
  <p>I have this string (there are more contents before and after the h2 tags):</p>
  
  <pre><code>...&lt;h2 style='line-height: 44px;'&gt;&lt;p&gt;Lorem Ipsum&lt;/p&gt;&lt;/h2&gt;...
  </code></pre>
  
  <p>What regex do I use to remove all the &lt;p> and &lt;/p> tags inside those header tags?</p>
  
  <p>I'm trying to do something like this, but the positive lookbehind one is not working:</p>
  
  <pre><code>// for the starting &lt;p&gt; tag
  $str = preg_replace('/(?&lt;=&lt;h[1-6]{1}[^&gt;]+&gt;)\s*&lt;p&gt;/i', '', $str);
  // for the ending &lt;/p&gt; tag
  $str = preg_replace('/&lt;\/p&gt;\s*(?=&lt;\/h[1-6]{1}&gt;\s*)/i', '', $str);
  </code></pre>
  
  <p>This does not take account paragraph tags deep inside the text within the &lt;h2> tag also</p>
  
  <p><strong>[Update]</strong></p>
  
  <p><em>This is derived from one of PeeHaa's suggested links</em></p>
  
  <pre><code>// for the starting &lt;p&gt; tag
  $str = preg_replace("#(&lt;h[1-6].*?&gt;)&lt;p.*?&gt;#", '$1', $str);
  // for the ending &lt;/p&gt; tag
  $str = preg_replace("#&lt;\/p&gt;(&lt;\/h[1-6]&gt;)#", '$1', $str);
  </code></pre>