[Mailman-Users] Filter to discard facebook invitations

Elaine Ashton elaine.ashton at oracle.com
Sun Apr 4 17:54:59 CEST 2010


On Apr 4, 2010, at 10:22 AM, John List wrote:

> Why doesn't the following discard_these_nonmembers filter work for facebook invitations:
> 
> ^[!@]*@facebookmail.com

In addition to what Mark has already pointed out, I thought I would add that the python regex documentation ( http://docs.python.org/library/re.html#re-syntax ) has a helpful routine for debugging regexen right on the command-line, e.g.

Python 2.6.4 (r264:75706, Feb 14 2010, 14:03:47) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> def displaymatch(match):
...     if match is None:
...         return None
...     return '<Match: %r, groups=%r>' % (match.group(), match.groups())
... 
>>> valid = re.compile(r"^[!@]*@facebookmail.com")
>>> displaymatch(valid.match("foobar at facebookmail.com"))
>>> displaymatch(valid.match("foo!bar at facebookmail.com"))
>>> displaymatch(valid.match("!foo!bar at facebookmail.com"))
>>> displaymatch(valid.match("@facebookmail.com"))
"<Match: '@facebookmail.com', groups=()>"
>>> displaymatch(valid.match("!@facebookmail.com"))
"<Match: '!@facebookmail.com', groups=()>"
>>> valid = re.compile(r"^.*[@.]facebookmail\.com")
>>> displaymatch(valid.match("foobar at facebookmail.com"))
"<Match: 'foobar at facebookmail.com', groups=()>"
>>> displaymatch(valid.match("foobar at bar.facebookmail.com"))
"<Match: 'foobar at bar.facebookmail.com', groups=()>"

I always find it handy since I like to be sure that I'm not matching more (or less) than I bargained for. :)

e.


More information about the Mailman-Users mailing list