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


in reply to Comment Removal

Here is yet another method, based on Regexp::Common:

use strict; use warnings; use Regexp::Common qw/comment/; # <== my $html = <<'END_HTML'; <p><b>Hello World</b> <!-- This comment would need to be removed from the entry --> </p><font color=red>It is Sunday!</font> <!-- also this--><p>this should stay here</p><!--this should go--> END_HTML $html =~ s/$RE{comment}{HTML}//g; # <== print "$html\n";

Result:

<p><b>Hello World</b> </p><font color=red>It is Sunday!</font> <p>this should stay here</p>