Regular Expressions 101

Community Patterns

Community Library Entry

-2

Regular Expression
PCRE (PHP <7.3)

/
<.[^>]*>(\s+|()|(&nbsp;)*|\s+(&nbsp;)*|(&nbsp;)*\s+|\s+(&nbsp;)*\s+)<\/.[^>]*>
/
ig

Description

Removes empty HTML tags. Was needed for old input clean-up and to keep a HTML parses from crashing. Looking for improvement on bottom test.

Submitted by R. Sartorius - 11 years ago