[Mailman-Users] Regexp for blocking addresses

Mark Sapiro mark at msapiro.net
Fri Sep 25 17:23:45 CEST 2015


On 9/25/15 7:57 AM, Matthew Saltzman wrote:
> 
> That's still much more aggressive than what I was trying to say. I
> actually want to ban precisely all variants of the one address
> 
>     joeblow at gmail.com
> 
> (and about a dozen other addresses) that include embedded periods
> anywhere and the suffix, but not other gmail addresses.  grep finds
> them with 
> 
>     \.\?j\.\?o\.\?e\.\?b\.\?l\.\?o\.\?w\.\    ?+.*@gmail    \.com
> 
> (I might want \.* instead of \.\?) but adding
> 
>     ^\.\?j\.\?o\.\?e\.\?b\.\?l\.\?o\.\?w\.\    ?+.*@gmail\.com
> 
> to the ban list doesn't seem to block them.


Because in a python RE, \? is a literal '?', not a '0 or 1 of repeat'.
For grep you need the \? to give ? its special meaning. a regexp for
egrep or grep -E will be closer to what you want for python. You want

^\.?j\.?o\.?e\.?b\.?l\.?o\.?w xxx \+.*@gmail\.com

where I'm unsure about the ' xxx ' part because I don't understand what
'\     ?' is supposed to do?

Or instead of the above and to account for multiple '.' maybe

^\.*j\.*o\.*e\.*b\.*l\.*o\.*w\.*\+.*@gmail\.com

which says zero or more dots followed by j followed by zero or more dots
followed by o, etc., followed by w followed by zero or more dots
followed by + followed by anything followed by @gmail.com.

See <https://docs.python.org/2/library/re.html#regular-expression-syntax>.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the Mailman-Users mailing list