procmail
[Top] [All Lists]

Re: regex to detect 20+ characters

2010-08-17 14:11:38
Andrew wrote:
My recepe should divert matches to a junk mailbox and ignore non matching 
emails.  I adapted another working recepe and tried to incorporate your 
solution.  Here is what I used, I suspect I'm doing the wrong thing with the 
braces { }.  Any help much appreciated:

:0
* Subject:.*[a-z]{10,}
{    EXITCODE=99
  :0 i
  ! junk(_at_)example(_dot_)com
}

In fact procmail doesn't understand the {10,} syntax. If you want to
have [a-z], say, 3 times, you have to write it 3 times: [a-z][a-z][a-z].
You can simplify that a bit by defining variables, though:

ALNUM="[a-z0-9]"
ALNUM5="$ALNUM$ALNUM$ALNUM$ALNUM$ALNUM"
ALNUM20="$ALNUM5$ALNUM5$ALNUM5$ALNUM5"

(There's no need to include "A-Z" as well, procmail's matching is
case-insensitive by default.) Now you can use "$ALNUM20" in your
condition if you add an initial "$" so that procmail knows it's supposed
to evaluate the variable (otherwise the "$" would be interpreted as "end
of line"):

:0
* $ ^Subject:.*$ALNUM20
! junk(_at_)example(_dot_)com

/HW
____________________________________________________________
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

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