in reply to Re^5: Looking for ideas on how to optimize this specialized grep
in thread Looking for ideas on how to optimize this specialized grep
In quoted something case like "", <html>, sometimes I saw negator was used as if to supress backtracking.
Do you mean [^"]* backtracks internally?$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";
My question (what I don't get) is 'Where the double quote gone when this regex matches againt To:<marmot@furrytorium.com> ?' Below is my simplified further example.
$text = <<'EOT'; Message-ID: <ODM2bWFpbGVyLmRpZWJlYS40MjYyNjE2LjEyOTU1NDE2MTg=@out-p-h. +customernews.net> To: "Angie Morestead" <marmot@furrytorium.com> EOT my @tos=( q(To:"Furry Marmot" <marmot@furrytorium.com>) ,q(To:"Mr.Furry Marmot" <marmot@furrytorium.com>) ,q(To:"pharmacy" <marmot@furrytorium.com>) ,q(To:<marmot@furrytorium.com>) ,q(To:<test@furrytorium.com>) ); 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* <marmot\@furrytorium\.com> }mx || $text =~ m{ ^(?:From|To): \s* <marmot\@furrytorium\.com> }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+ # <marmot\@furrytorium\.com> }mx ){ print "### Spam!! ,matched=#$&#\n"; }else { print "### not Spam!!\n"; } print "\n\n"; }
And why "To:<test@furrytorium.com>" is not Spam...? I think I'am missing something... Anyway I should print out prelretut. thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Looking for ideas on how to optimize this specialized grep
by furry_marmot (Pilgrim) on Jan 28, 2011 at 00:55 UTC | |
by remiah (Hermit) on Jan 28, 2011 at 07:51 UTC |