S='
not_show_1
show_1
not_show_2
show_2' echo $S | perl -pe 's!$1[^<]+!! while (/(]+>)/)' show_1 show_2