my $tag = qr{ <(?>/?) # tag start (?!sup) # not a or tag [^>]* # everything but the tag end+ > # end of tag }xi; $str =~ s/$tag//g;