regex with specific list of string

Steve Holden steve at holdenweb.com
Wed Sep 26 12:49:10 EDT 2007


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'
> 
> Thanks

 >>> patr = re.compile('jan|feb|mar|apr|may|jun|jul|aug|sep|nov|oct|dec')
 >>> patr.match("jul")
<_sre.SRE_Match object at 0x7ff28ad8>
 >>> patr.match("nosuch")
 >>>

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline




More information about the Python-list mailing list