Jason LaMar wrote:

>Thanks for helping me out with this. As a follow-up question, because
>(obviously) I'm a regexp newbie: If I wanted to use this statement as a
>basis ...
>
>\nfrom:[EMAIL PROTECTED]@(?!fubar.com[>\s])
>
>... BUT I also wanted to allow messages from any fubar.com sub-domain
>(mail.fubar.com, as an example), how should I modify this regexp to
>accommodate that? If it would make it any easier, the specific (additional)
>sub-domain I would need would be cc.fubar.com.


Actually, my original regexp is not quite right. In practice it
probably makes no difference, but fubar.com in the above will also
match and accept fubarxcom or fubarzcom, etc. since . matches
anything, but since without an actual ., it wouldn't be a valid
domain, it really doesn't matter. The strictly correct version of the
above is

\nfrom:[EMAIL PROTECTED]@(?!fubar\.com[>\s])

i.e, put a \ in front of the . to make it match literally a .

For fubar.com and cc.fubar.com, you could use

\nfrom:[EMAIL PROTECTED]@(?!(cc\.)?fubar\.com[>\s])

which will match 0 or 1 'cc.' followed by fubar.com or you could use

\nfrom:[EMAIL PROTECTED]@(?![^@>\s]*fubar\.com[>\s])

which will match 0 or more of any single character except @, > or white
space followed by fubar.com.

There are lots of other ways to do this too, but those should get what
you want.

A different approach which is more flexible for adding more domains is
to have a series of 'accept' rules each matching a simple pattern (or
one accept rule with multiple patterns) followed by a discard rule
that matches anything. E.g., in the accept rule put

\nfrom:[EMAIL PROTECTED]@fubar\.com[>\s]
\nfrom:[EMAIL PROTECTED]@cc\.fubar\.com[>\s]

and in the discard rule just put

^

(which will match at the beginning of the headers string and thus will
match any message at all and discard any message that wasn't matched
in the preceding rule(s)). Then you can easily add additional patterns
to the accept rule if it becomes necessary to accept additional
domains.

-- 
Mark Sapiro <[EMAIL PROTECTED]>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

------------------------------------------------------
Mailman-Users mailing list
Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Security Policy: 
http://www.python.org/cgi-bin/faqw-mm.py?req=show&amp;file=faq01.027.htp

Reply via email to