regex with specific list of string

Carsten Haese carsten at uniqsys.com
Wed Sep 26 11:54:15 EDT 2007


On Wed, 2007-09-26 at 15:42 +0000, james_027 wrote:
> hi,
> 
> how do I regex that could check on any of the value that match any one
> of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
> 'sep', 'oct', 'nov', 'dec'

Why regex? You can simply check if the given value is contained in the
set of allowed values:

>>> s = set(['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
'sep', 'oct', 'nov', 'dec'])
>>> 'jan' in s
True
>>> 'spam' in s
False

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list