procmail
[Top] [All Lists]

Re: Searchhing for words in external word list?

2008-12-11 11:21:52
At 10:44 2008-12-11 +0000, Dave Wood did say:

Well I messed this up. I know now that [ ]  means excluding. But changing
the test to

No, [] encapsulates a character class. [a-z] would mean match any single letter. no hyphens would match individually specified symbols.

You might benefit from reading the procmail manpages.

* ^Subject:.*${BADWORDS}*

doesn't seem to work. Am I right in thinking that procmail is treating the
 | characters as part of the search string rather than an operator?

Well, you'd want to encapsulate the massive or'd list (else an or would evaluate to everything on one side of it - the first token in your list would evaluate with the ^Subject:.* part, but the rest would not), and lose the trailing asterisk (which would match on ZERO or more of the preceeding token). Also, cram a $ before the regexp so that the variable is expanded before the evaluation:

* $ ^Subject:.*($BADWORDS)

Those are parenthesis, not braces. The braces you're using will cause regexp operators in the BADWORDS variable to be escaped so that they could be evaluated as literals. For example:

        donkey|ape|zebra

        would become:

        donkey\|ape\|zebra

Which would have the effect of making the Subject need to match the whole lot.


BTW, you need to be prepared for your badwords list to get screwed up - if you're editing it right at the time it gets used for an evaluation, what do you figure happens if BADWORDS is an empty list?


I use a different tact for wordlist matching: the wordlist file has one word per line, and I basically invoke grep on the match line. In actuality, I'm using a specialized program to accomplish this, but a grep equivalent would be something like:

:0
* ? formail -xSubject: | fgrep -i -f $BADWORDS
spam

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

____________________________________________________________
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