[Mailman-Users] topic regep exclude

Howard Moscovitz h at mosc.com
Sun Sep 26 05:37:59 CEST 2004


Mark Sapiro wrote:

>Howard Moscovitz wrote:
>
>  
>
>>In the topic definition form, how can one specify a topic that is only 
>>messages that DOES NOT have the string [G2] in it.
>>    
>>
>
>see http://docs.python.org/lib/re-syntax.html
>
>I would try
>
>  ^(?!.*\[G2\])
>
>or if case is not significant
>
>  ^(?!.*\[[Gg]2\])
>
>but this is only a suggested starting point. It seems to me that it
>should work, but I don't know.
>
>  
>
>>Is there a way to test regeps without setting up a separte test list?
>>    
>>
>
>You could do a few interactive tests with Python or make a script.
>
>For example:
>
>[gpc_ms at clint ~]$ python2.3
>Python 2.3.3 (#1, Mar  4 2004, 22:12:33)
>[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
>  
>
>>>>import re
>>>>m = re.match('^(?!.*\[G2\])', 'now is the time for [G3] to do something')
>>>>m.group(0)
>>>>        
>>>>
>''
>  
>
>>>>m = re.match('^(?!.*\[G2\])', 'now is the time for [G2] to do something')
>>>>m.group(0)
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: 'NoneType' object has no attribute 'group'
>  
>
>[gpc_ms at clint ~]$
>
>In the first case, the re matches the null character at the beginning
>of the line which is followed by not (anything followed by [G2]) so
>the match succeeds and the matched string is null.
>
>In the second case, the null character at the start of the string is
>followed by (anything followed by [G2]) so the match fails and m.group
>is undefined.
>  
>
Well, I was able to duplicate this result using Python on my computeras 
you suggested, thank you. I put that regep in the topic filter and 
people who have selected that topic are still getting messages with [G2] 
in the subject. Do you have to put the regep in quotes, single or 
double, on the admin form?

--Howard





More information about the Mailman-Users mailing list