title: Remove unwanted tags using regular expression in PHP
body: <p>I want to remove <code>&lt;p&gt;</code> tags from my string having spaces or blanks or <code>&lt;br /&gt;</code> inside. I tried this one                    </p>
  
  <pre><code>$html = "abc&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;dd&lt;/p&gt;&lt;b&gt;non-empty&lt;/b&gt;"; 
  $pattern = "/&lt;p[^&gt;]*&gt;(&amp;nbsp;|\s)&lt;\\/p[^&gt;]*&gt;/"; 
  //$pattern = "/&lt;[^\/&gt;]*&gt;([\s]?)*&lt;\/[^&gt;]*&gt;/"; use this pattern to remove any empty tag
  
  echo preg_replace($pattern, '', $html); 
  </code></pre>
  
  <p>This works fine. It's removing spaces only. Thanks in advance.</p>