procmail
[Top] [All Lists]

Re: regexp to match x BEFORE y

2002-02-12 15:08:20
On 12 Feb, J-Dog wrote:
| [...]
| 
| I run numerous opt-in mailing lists, and quite often have users who just
| click reply and type "remove" or "unsubscribe" in the body of the message
| and then send the message back to me. Normally this would be easy to catch
| with procmail, simply scanning the body for "remove" or "unsubscribe". My
| problem arises from the fact that most of the customers who reply to the
| emails leave the original message in the reply, and the original message
| contains the words "remove" and "unsubscribe".
| 
| So, I want to match the word "remove" anywhere in the body BEFORE the text
| "original message". I created the regexp below to handle this, but it is
| not working for me. I realize that this is probably because my regexp is
| ugly, so, any help fixing it would be greatly appreciated.
| 
| :0B:
| * .*remove.*.$.*original message.*
| /home/foo/mail/remove
| 

:0B:
* remove(.*\>?)*original message
home/foo/mail/remove

should match what you ask, which I read to be that any number of lines,
with any content, may or may not appear between "remove" and "original
message". But that will catch any top posted message from an Oulook user
with the word remove anywhere in *their* contribution. I would think
something like this would be safer:

:0B:
* ^[    ]*remove[       ]*$(.*\>?)*original message
home/foo/mail/remove

( a <space> and a <tab> in the [] enlosed character classes.)

This should match "remove" on a line by itself (w/ optional leading or
trailing whitespace but nothing else), the string "original message"
following, with anything or nothing in between, before, and after.

-- 
Reply to list please, or append "6" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


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