On 7 Feb 2005 Ruud H.G. van Tol (rvtol(_at_)isolution(_dot_)nl) wrote:
The wrong form is:
^From:.*cmathew|horvath|name-3|name-4
because in there, name-1 equals '^From:.*cmathew'.
Good explanation Ruud. Another way to think about this precedence
stuff is to think about good old multiplication and addition in
arithmetic. If you have an expression like this:
abc+def
there are lots of ways it could be parsed, but the convention is
that multiplication takes precedence over addition, so this
expression should be parsed like this:
(abc)+(def)
But note that the parentheses are not needed in this case. The
only time that parens are needed is if you are doing something
other than the default.
Birl's regular expression was this:
^From:.*(cmathew)|(horvath)
which is equivalent to this:
^From:.*cmathew|horvath
because "multiplication" takes precedence over "addition"
(ORing).
And these two are equivalent to this:
(^From:.*cmathew)|(horvath)
Again because "multiplication" takes precedence over "addition."
Parens are not needed in any of these three expressions. And they
all mean
EITHER the expression
^From:.*cmathew
OR the expression
horvath
When you want to use a non-default precedence, that's when you
need parens, for example in the arithmetic expression above, you
could say this:
ab(c+def)
and this is essentially equivalent to what Birl wants:
^From:.*(cmathew|horvath)
I think that the confusion might be because '.*' looks like an
operator that might have a lower precedence than '|', but in fact
it is simply a STRING. If we write it this way:
^From:STRINGcmathew|horvath
I think it is more clear why we need parens and where we need
them.
Nancy
(ex Math teacher)
--
Infinite Ink: <http://www.ii.com/>
Procmail Quick Start: <http://www.ii.com/internet/robots/procmail/qs/>
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail