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 <[email protected]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
------------------------------------------------------
Mailman-Users mailing list [email protected]
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/archive%40jab.org

Reply via email to