You have provided a regular expression and some sample data. You say that the regular expression removes "snippet of code" from your sample data, but it does not.
Here, I've adapted blokhead's framework and plugged in your regular expression and your data:
#!/usr/bin/perl -w
use strict;
my $comments = do { local $/; <DATA> };
print "BEFORE:\n$comments";
$comments =~ s/<!--(.|\s)*?-->//g;
print "AFTER:\n$comments";
__DATA__
<!-- comments -->
snippet of code
<!-- comments -->
The output is:
BEFORE:
<!-- comments -->
snippet of code
<!-- comments -->
AFTER:
snippet of code
If you want to have someone debug your problem, you'll have to provide the real regular expression you're using or the real data. (And, yes, I did test it out with multi-line comments, too.)
BTW, $comments is a little strange as a name for text which includes more than just comments. Are you sure that it contains the snippet of code before you apply the regular expression?
--
Eric Hammond |