procmail
[Top] [All Lists]

Re: (^TO|Subject:.) question

1999-08-14 05:38:25
On 13 August 1999, S.Toms <skull(_at_)primenet(_dot_)com> wrote:
 Ok, seeing the explanation of how the above works, I was wondering if
something like the following is valid or not.
  * (^X-Mailinglist|Subject):.(*suse-linux-e|*[SLE])

or would it be like this?
  * (^X-Mailinglist|Subject:.)(*suse-linux-e|*[SLE])

    [*Sigh*] Repeat after me: regexp syntax is NOT the same as shell
syntax.  Unlike the shell syntax, "*" means "repeat the previous
expression 0 or more times".  In your case, "(*" will match 0 or more
"(". What you want is ".*" which means "match any character 0 or more
times".

  I kinda would think in the above example, i would have to move
the ^ to the left of the first ( so that its included in either the
X-Mailinglist or the Subject, am I wrong about that?

    No (that is, you're right, it should go outside).

  Also what about the :. symbols, would I move them to the right of the
first ) like the first example, or leave them as is in the second?

    The ":" applies to both expressions, so you have to move it outside.
OTOH, "." means "any character", and you don't want to separate it from
the "*". Also, if you want to match literal brackets "[" and "]" you
have to escape them.  What you want is

        * ^(X-Mailinglist|Subject):.*(suse-linux-e|\[SLE\])

    That said, it still looks strange to mix addresses with subjects.
Are you sure you want to catch messages with

        X-Mailinglist: [SLE] something
or
        Subject: suse-linux-e(_at_)suse(_dot_)com  ?

If you just want to catch messages with either

        X-Mailinglist: suse-linux-e(_at_)suse(_dot_)com
or
        Subject: [SLE] something

just use two recipes:

        :0:
        ^Subject:.*\[SLE\]
        suse

        :0:
        ^X-Mailinglist:.*suse-linux-e@
        suse

  I believe I understand it, but only to a certain extent :)

    Reading a book about regular expressions (or even the description in
the procmail man pages) might help.

    Regards,

    Liviu Daia

-- 
Dr. Liviu Daia               e-mail:   Liviu(_dot_)Daia(_at_)imar(_dot_)ro
Institute of Mathematics     web page: http://www.imar.ro/~daia
of the Romanian Academy      PGP key:  http://www.imar.ro/~daia/daia.asc

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