[Mailman-Users] how to use topics/ for more than one keyword

Mark Sapiro msapiro at value.net
Tue Feb 22 20:43:15 CET 2005


LN Tora wrote:

>First, my apologies.  I would have gone to the listowners site were it still 
>up, as I know this is a simple (and silly) question.

Actually, it's not that simple.

>I have a virtual domain, and Mailman 2.1.5p1 came with the package.  I was 
>able to set up a list easily enough, but I'm having trouble with 
>understanding/using the topics feature.  From what I can make out, I 
>actually have to use a regular expression to get it to match the categories 
>I'm using.  While I'm familiar with PHP and Perl to a much lesser extent, I 
>don't have a clue about Python.

Python regular expressions are described at
www.amk.ca/python/howto/regex/ and
www.python.org/doc/current/lib/re-syntax.html

>Basically, I would like to know a basic expression for matching more than 
>one keyword, using an "and" operator to ensure all the words are found.

Unfortunately, this is not something that is easily done with a single
regular expression. Suppose you want to both 'black' and 'white' and
they could occur in either order. The re '(black|white)' could be used
to match the first occurrence of one of these (ignoring that it would
also match 'blacker' and so forth) and '(black|white).*(black|white)'
would match a first occurrence, followed somewhere by a second, but
both could be 'black'. You would need something like
'(black.*white)|(white.*black)' to match both words in either order.
If you had three words, you would need six alternatives to specify all
the possible orderings.

In a programming situation you could say something like "IF 'black' is
in the string AND 'white' is in the string AND 'grey' is in the string
THEN ...". The nature of regular expressions is such that you can't do
this directly within a single regular expression. This is because an
re specifies a pattern to match against a string and while a pattern
can specify alternatives (e.g. black|white) meaning the next part of
the string is either black or white, the next part of a string can't
be both black and white at the same time so something like
'blackANDwhite' could never match.

--
Mark Sapiro <msapiro at value.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