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


in reply to Regular Expressions: Call for Examples

remove nested <table>...</table> elements
$_ = join'',<>; ($re=$_)=~ s#((<table[^>]*>)|(</table>)|<!--.*?-->|.)#${['(','']}[!$2]\Q$1\E${[') +','']}[!$3]#sgi; $re=join"|",map quotemeta,eval{/$re/}; die $@ if $@=~/unmatched/i; s/$re//g; print;