#!/usr/bin/perl
$regex = '(<\/?p[^>]*>)|<[^>]*>';
$subject = 'Bad html <a> </I> <p>My paragraph</p> <i>Italics</i> <p class="blue">second</p>';
($replaced = $subject) =~ s/$regex/$1/eg;
IyEvdXNyL2Jpbi9wZXJsCiRyZWdleCA9ICcoPFwvP3BbXj5dKj4pfDxbXj5dKj4nOwokc3ViamVjdCA9ICdCYWQgaHRtbCA8YT4gPC9JPiA8cD5NeSBwYXJhZ3JhcGg8L3A+IDxpPkl0YWxpY3M8L2k+IDxwIGNsYXNzPSJibHVlIj5zZWNvbmQ8L3A+JzsKKCRyZXBsYWNlZCA9ICRzdWJqZWN0KSA9fiBzLyRyZWdleC8kMS9lZzsKcHJpbnQgJHJlcGxhY2VkIC4gIlxuIjs=