You are absolutely right. So how can I update my code above, except from stating here:
Update (thanks to antirice):
my $qs =qr/'(?:[^\\']|\\.)*'/; my $qqs=qr/"(?:[^\\"]|\\.)*"/;
#!perl use strict; my $qs =qr/'(?:[^\\']|\\.)*'/; my $qqs=qr/"(?:[^\\"]|\\.)*"/; my $ncs=qr<(?:[^'"/]|/[^/*])>; #' my $nocomment=qr/(?:$ncs|$qqs|$qs)*/; my $hit; while (<>) { s/[\r\n]//g; # remove multiline /* comment if ($hit= s{^($nocomment)/\*(?:[^*]|\*[^/])*$}{$1}o ... s{^.*? +\*/}{}) { redo if $hit=~ /E0/i; $_='' if $hit>1; print $_,"\n"; next; } # remove one-line /*...*/ comment redo if s{^($nocomment)/\*.*?\*/}{$1}o; # remove // comment s{^($nocomment)//.*}{$1}o; print $_,"\n"; }
In reply to Re: Re: strip JS-comments
by Skeeve
in thread strip JS-comments
by Skeeve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |