procmail
[Top] [All Lists]

Re: Procmail Multiple-Spam Catcher Recipe?

2002-01-16 08:31:03
Actually, this question is about how to say "or" in a regexp and not
specific to spam catching at all.

Kenneth Blackwell asked,

| 1. When I do this, each message source really is filtered to dufus:

| # Filter out Spam mail and delete it.
| #:0
| #* ^From:(_dot_)*x(_at_)mcmail(_dot_)cis(_dot_)mcmaster(_dot_)ca
| #dufus
| #:0
| #* ^From:(_dot_)*y(_at_)mcmail(_dot_)cis(_dot_)mcmaster(_dot_)ca
| #dufus

| 2. But when I try to combine sources like this,
|
| # Filter out Spam mail and delete it.
| #:0
| #* 
^From:(_dot_)*x(_at_)mcmail(_dot_)cis(_dot_)mcmaster(_dot_)ca,y(_at_)mcmail(_dot_)cis(_dot_)mcmaster(_dot_)ca
| #dufus
|
| only the first source is filtered.

You're trying to use a comma as an alternator, and all a comma means in a
regexp is a literal comma (well, at least in procmail's regexps).  You're
not going to get a message whose From: header has those two addresses glued
with a comma (and in that order too); nothing else will match that
expression.

If you say that the first address is caught, it must be when you're trying
some variation on the above, since the form you posted would fail for
either.

The way to say "or" with strings inside a regexp (not all programs that use
regexps support this, but procmail does) is to use a pipe symbol, and if the
two alternatives don't encompass the entire remainder of the expression, to
limit the extent with parentheses, like this:

 * 
^From:.*(x(_at_)mcimail(_dot_)cis(_dot_)mcmaster(_dot_)ca|y(_at_)mcmail(_dot_)cis(_dot_)mcmaster(_dot_)ca)

Since the two domains are the same, we can limit the alternation to the
local parts; also, the periods should be escaped so that they'll match only
on literal periods:

 * ^From:.*(x|y)@mcimail\.cis\.mcmaster\.ca

I'm assuming that "x" and "y" are substitutes for longer strings and not
literally single characters; if you want to give a choice of one character
from a set or a range, you'd use brackets rather than parentheses and a
pipe.

Finally, if "dufus" is a file rather than a directory, use a local lockfile
on that recipe:

 :0:
 * ^From:.*(x|y)@mcimail\.cis\.mcmaster\.ca
 dufus

{That must be the Canadian spelling of "doofus," or maybe it's French for
"some [whatever <<fus>> means]," where <<fus>> is one of those French nouns
that has the S pronounced in the singular and silent in the plural, like
<<os>> or <<tumulus>>.}



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>