$a=q("aaa" and "bbb"); $a =~ s/".*"/test/g; print "back tracked #$a#\n"; $a=q("aaa" and "bbb"); $a=~ s/"[^"]*"/test/g; print "with negator #$a#\n"; $a=q("aaa" and "bbb"); $a=~ s/".*?"/test/g; print "with backtrack supress #$a#\n"; #### $text = <<'EOT'; Message-ID: To: "Angie Morestead" EOT my @tos=( q(To:"Furry Marmot" ) ,q(To:"Mr.Furry Marmot" ) ,q(To:"pharmacy" ) ,q(To:) ,q(To:) ); foreach my $to( @tos){ $text =~ s/To:.*/$to/; print "$text\n"; ###two condition version if ($text =~ m{ ^(?:From|To): \s* ".*Furry\s{1}Marmot" \s* }mx || $text =~ m{ ^(?:From|To): \s* }mx ) { print "### with two cond, ok, matched=#$&#\n"; }else { print "### with two cond, ng\n"; } ###one condition if ($text =~ m{ ^(?:From|To): #From: or To: \s* " #<---here Where are you gone? (?!.*Furry\s+Marmot) # [^"]* # " # \s+ # }mx ){ print "### Spam!! ,matched=#$&#\n"; }else { print "### not Spam!!\n"; } print "\n\n"; }