http://www.perlmonks.org?node_id=26723


in reply to Small HTML parser

There has got to be a better way to do it, but this is a slow hack that will work:
my $list = join('|', @allowed_tags); $dirty_html =~ s!<\s*/?\s*(\w+).*?>!($a,$b)=($&,$1); $a if $b =~ /^(?: +$list)$/!esg;