in reply to Perl pattern matching

See the first example of HTML::Filter. It's a comment stripper, so all you need to do is reverse that.