Help with a regular expression

The WYSIWYG editor in the CMS I’m using encloses tables in paragraphs. <p><table>
This is causing a problem when it interfaces with another tool.

I’m trying to remove the unwanted paragraph tags on the back side. It would need to be able to handle <p><table>, <p>[whitespace]<table>, <p> <table class=‘data’>, etc…

This is what I’ve come up with so far.


Any help would be appreciated



Try that

Honestly though, it sounds like putting band-aids on a gunshot wound and you’ll have other issues as well with that editor, should use something better.

$str = preg_replace('~<p>\\s*(<table(.*?)</table>)\\s*</p>~i', "$1", $str);