The following PHP regex removes all empty tags:
#<[^\/>]*>([\s]?)*<\/[^>]*>#u
I want to remove empty tags that do not match:
<div style="clear:both"></div>
I tried:
#^(<div style="clear:both"></div>)<[^\/>]*>([\s]?)*<\/[^>]*>#u
…but it didn’t work.
How do I add a negation?
Assuming that it is well-formed and there are no missing end tags, this should do the trick:
Make sure to use the case-insensitivity flag too. I would still advise against it, though.
EDIT: I haven’t tested my edits, but I’m fairly confident that it’s a bit more thorough.