I use TinyMCE (WYSIWYG) as the default editor in one of my projects, and sometimes it automatically adds <p> </p> , <p> </p> or divs.
I searched but could not find a good way to clear any empty tags using regular expressions.
The code I tried to use is
$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/"; $str = preg_replace($pattern, '', $str);
Note. I also want to clear & nbsp :(
jnbn source share