Re: Matching literal dot in To
"Ruud H.G. van Tol" <[email protected]> Sun, 14 Jun 2015 16:52:18 +0200
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <[email protected]> |
On 2015-06-14 15:50, Erik Christiansen wrote: > On 14.06.15 08:30, Chuck Martin wrote: >> On Sun, Jun 14, 2015 at 07:38:30PM +1000, Erik Christiansen wrote: >>> We need another tweak. This will be a great deal closer: >>> >>> * ^TO_.*\<[^.@ ]+\.[^.@ ]+@ >>> >>> That will not leap to the end of a mismatched address, but slide off it >>> in stages, because '\<' is only shorthand for `[^a-zA-Z0-9_]'. But we >>> needn't fuss over a lost microsecond here or there. It should do the job >>> now. >> >> That will miss an address like [email protected]. > > That is not within the stated parameters. The stated goal is to detect > xxx.yyy@zzz But even if we assume that you have imagined a real need, > that does not mean that your "It may be necessary" is in any way > required. > > Since '\<' is only shorthand for `[^a-zA-Z0-9_]', it is only necessary > to substitute the negative character class for the shorthand, and extend > it to [^a-zA-Z0-9_+]. > > Whether that is considered worth doing, we can but ask. I didn't test it yet, but I think that .* is non-greedy outside of matches (and greedy within), so it should work fine also for plussed addresses. So let's do a test: $ cat testrc #!/usr/bin/procmail -m LOGABSTRACT=no VERBOSE=no n=" " LOG="${n}Starting ...$n" :0 * ^TO_.*\<[^.@ ]+\.[^.@ ]+@ { LOG="FOUND$n" } :0 * ^TO_.*\<\/[^.@ ]+\.[^.@ ]+@[^, ]+ { LOG="MATCH: $MATCH$n" } LOG="Done.$n$n" - - - - - - $ chmod -vv u+x testrc testrc: 0100644 [-rw-r--r-- ] -> 0100744 [-rwxr--r-- ] - - - - - - $ echo "To: [email protected] [email protected] [email protected]" | ./testrc Starting ... FOUND MATCH: [email protected] Done. -- Greetings, Ruud