procmail
[Top] [All Lists]

Re: or statements

2003-09-14 12:21:27
Thanks all for you help. Much appriciated!

Manoj


Andrew Edelstein wrote:

On Sun, Sep 14, 2003 at 01:23:29PM -0400, DZ-Jay wrote:
:0:
* ^(From).*senderID@ | ^(From)(_dot_)senderID2(_at_)* | 
^(From)(_dot_)senderID3(_at_)*
sender
The reason it doesn't work is because of the spaces between the ORs
'|', i.e. procmail is trying to match '^(From).*senderID@ '.  I also
think (please someone correct me if I'm wrong) that procmail will OR
the immediate strings surrounding it, in your case, the spaces.  So
instead of trying to find 1 of 3 expressions, it is trying to match
something like:

Partially correct. Parens indicate to match against the enclosed GROUP of
expressions. (From) is not a group, it is a single expression, whereas
(senderID|senderID2|senderID3) is three separate expressions, OR'd. He had it
mostly right. He just didn't have the parens in the right place, and was
duplicating parts of the expression he didn't need to. You are correct on the
spaces.

Not that you should use do this, but this would work:

* 
(^From.*senderID@)|(^From(_dot_)*senderID2(_at_)(_dot_)*)|(^From(_dot_)*senderID3(_at_)(_dot_)*)

No, it wouldn't. Procmail needs a single expression. THAT expression can have
multiple expression's within it, using regexp syntax.
Closer to what you're trying to do here would be:

        * 
(^From(_dot_)*senderID(_at_)(_dot_)*|^From(_dot_)*senderID2(_at_)(_dot_)*|^From(_dot_)*senderID3(_at_)(_dot_)*)

This would work, but is less efficient. Since "^From.*" is the same in all
three, we don't need to repeat it in the OR. The "@.*" is completely
unneccessary, but can be included if you want, but the same applies to it,
thus we get:

        * ^From.*(senderID|senderID2|SenderID3)@.*

Note that these two will match almost exactly the same thing; the later is
just a leaner, more efficient version of the former.
It's the difference between saying
"I want to match the string '^From(_dot_)*senderID(_at_)(_dot_)*' OR the string '^From(_dot_)*senderID2(_at_)(_dot_)*' OR the string '^From(_dot_)*senderID3(_at_)(_dot_)*'"
or
I want to match the string "^From.* 'senderID OR senderID2 OR senderID3' @.*"
        




_______________________________________________
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>