procmail
[Top] [All Lists]

Need regex-help: inverted word search

2004-11-05 11:45:49
Hi,

I have some difficulties with finding the correct regular expression for my problem.

I sometimes get mails where other accounts on the same server are listed in the To-header as well, e.g.:

        To: someone(_at_)server, myname(_at_)server, somebodyelse(_at_)server

Now I look for a way to do an inverse word search, like this:
        * To: (not myname)@server

I can look for specific strings:
(1)     * To:(_dot_)*myname(_at_)server

or for one of different strings:
(2)     * To:.*(myname|othername)@server

I can look for any combination of a given set of characters:
(3)     * To:(_dot_)*[mynae]+(_at_)server

and for any combination of characters not containing chars of a given set:
(4)     * To:(_dot_)*[^mynae]+(_at_)server

Now, is there a way to do something like (4), only not for character but strings? The problem is that any mail that reaches me contains my address, so it always matches
        * To:(_dot_)*myname(_at_)server

Something like
(5)     * ! To:(_dot_)*myname(_at_)server
does, therefor, not work.

I could find a mail addressed to me and, say, XXX, YYY, or ZZZ with something like (2). However, that would be impractical as there are too many users on this server to include them all and sometimes such mail is also sent to non-existent accounts. An inverse search for (not_myname) would be more general and catch not only to XXX, YYY, or ZZZ, but also for AAA.

I tried to simulate inverse matching by combining patterns like in (4):
(6)     * To:.*([^m][^y][^n][^a][^m][^e])@server
However, that does only match if the name of another account has at least as many characters as mine. Thus, that rule would match for XXXXXX, but not for XXX. I've tried to modify that:

(7)     * To:.*([^m]*[^y]*[^n]*[^a]*[^m]*[^e]*)@server
But this is too fuzzy again and also matches mails only sent to my account.

So, does anybody have an idea how to do that?

Best regards,

Andreas

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