Help with regular expression filters

I have a filter to block the word "test" from Subject because some people won't receive list mail for a few hours and think it's broken so they post "test" And once one person does it everybody else feels obligated to "test". So I use Subject: .*test Problem with that is that it also blocks "latest" and "testimony". I suck at regular expressions and would appreciate some help. I also don't have a test list to test this :)
Thanks Marino Pascal

At least in Emacs the following regexp works
\_<test\_>
that finds 'test' but not 'fastest' or 'testy'
bash, perl, ruby, etc. may have different ways of doing the same thing.
ed
On Tue, Feb 3, 2015 at 12:46 PM, Marino Pascal <mpascal@gmail.com> wrote:
I have a filter to block the word "test" from Subject because some people won't receive list mail for a few hours and think it's broken so they post "test" And once one person does it everybody else feels obligated to "test". So I use Subject: .*test Problem with that is that it also blocks "latest" and "testimony". I suck at regular expressions and would appreciate some help. I also don't have a test list to test this :)
Thanks Marino Pascal
Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/eminmn%40sysmatrix.net

On 02/03/2015 12:08 PM, e.c. wrote:
At least in Emacs the following regexp works
\_<test\_>
that finds 'test' but not 'fastest' or 'testy'
bash, perl, ruby, etc. may have different ways of doing the same thing.
In Mailman, with Python regexps <https://docs.python.org/2/library/re.html>, I would use
^Subject:.*\Wtest\W
\W matches any 'non-word' character and is equivalent to [^a-zA-Z0-9_], i.e. anything including new-line which is not a letter, digit or underscore.
import re cre = re.compile('^Subject:.*\Wtest\W', re.IGNORECASE) s1 = """Subject: This is a test of mailman.""" s2 = """Subject: This is a test.""" s3 = """Subject: I am testing...""" s4 = """Subject: This is a test ... """ cre.search(s1) <_sre.SRE_Match object at 0x7f740d0abac0> cre.search(s2) <_sre.SRE_Match object at 0x7f740d0abb28> cre.search(s3) cre.search(s4) <_sre.SRE_Match object at 0x7f740d0abac0>
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

On Tue, 03 Feb 2015 21:43:09 -0000, Mark Sapiro <mark@msapiro.net> wrote:
In Mailman, with Python regexps <https://docs.python.org/2/library/re.html>, I would use
^Subject:.*\Wtest\W
\W matches any 'non-word' character and is equivalent to [^a-zA-Z0-9_], i.e. anything including new-line which is not a letter, digit or
underscore.
I trap with - ^subject:.*\btest.* - accepting \W is the better option, I
tail it with .* as I want to catch 'testing' as well as 'test' :-)
I also have traps - ^subject:.*virus.* - on 'virus', 'spam' and 'digest'
:-)
What I would really like is a (simple) way to trap the absence of a
subject header but I think, we can (understandably) only trap on the
content of something that is present :-(
= Malcolm.
-- Malcolm Austen <malcolm.austen@weald.org.uk> GENUKI trustee <genuki@weald.org.uk> Pedigree User Group <chairman@pugweb.org.uk> Oxfordshire FHS <webmaster@ofhs.org.uk> FFHS Communications Officer <communications@ffhs.org.uk>

Malcolm Austen writes:
What I would really like is a (simple) way to trap the absence of a
subject header but I think, we can (understandably) only trap on the
content of something that is present :-(
As a workaround, procmail supports negative assertions of that kind:
:0:
- ! ^Subject no-subject-bitbucket
would do what you want. That may not be acceptable to you, of course, depending on the facilities available to you, or convenience. Just throwing it out there, somebody might find it useful.
I don't think it would be hard to add this feature if there's no way to do it, although Mark may not want to do it in 2.1.x. Wait for Mark and if he says it can't be done in current Mailman, I'd suggest filing an RFE at https://launchpad.net/mailman.
Steve

On 02/04/2015 06:04 AM, Stephen J. Turnbull wrote:
Malcolm Austen writes:
What I would really like is a (simple) way to trap the absence of a
subject header but I think, we can (understandably) only trap on the
content of something that is present :-( ...I don't think it would be hard to add this feature if there's no way to do it, although Mark may not want to do it in 2.1.x. Wait for Mark and if he says it can't be done in current Mailman, I'd suggest filing an RFE at https://launchpad.net/mailman.
In my production Mailman, I do it as part of the tests in a custom handler, but see the FAQ at <http://wiki.list.org/x/8683854> for a way to do it with header_filter_rules.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

On Wed, 04 Feb 2015 15:56:14 -0000, Mark Sapiro <mark@msapiro.net> wrote:
Malcolm Austen writes:
What I would really like is a (simple) way to trap the absence of a subject header but I think, we can (understandably) only trap on the content of something that is present :-( ...
In my production Mailman, I do it as part of the tests in a custom handler, but see the FAQ at <http://wiki.list.org/x/8683854> for a way to do it with header_filter_rules.
Thank you Mark, I had missed that in the FAQ (slaps wrist). It makes
perfect sense once explained!
= Malcolm.
-- Malcolm Austen <malcolm.austen@weald.org.uk> GENUKI trustee <genuki@weald.org.uk> Pedigree User Group <chairman@pugweb.org.uk> Oxfordshire FHS <webmaster@ofhs.org.uk> FFHS Communications Officer <communications@ffhs.org.uk>

On Tue, Feb 03, 2015 at 10:46:39AM -0800, Marino Pascal wrote:
I have a filter to block the word "test" from Subject because some people won't receive list mail for a few hours and think it's broken so they post "test"
People who send test mails to lists I manage usually find themselves moderated.
-- "I am firm. You are obstinate. He is a pig-headed fool." -- Katharine Whitehorn
participants (6)
-
Adam McGreggor
-
e.c.
-
Malcolm Austen
-
Marino Pascal
-
Mark Sapiro
-
Stephen J. Turnbull