[Tutor] advice on regex matching for dates?
Kent Johnson
kent37 at tds.net
Thu Dec 11 21:11:50 CET 2008
On Thu, Dec 11, 2008 at 2:31 PM, Serdar Tumgoren <zstumgoren at gmail.com> wrote:
> Hey everyone,
>
> I was wondering if there is a way to use the datetime module to check for
> variations on a month name when performing a regex match?
Parsing arbitrary dates is hard, in fact the most general case is not
solvable since 7/8/07 could refer to July 8 or August 7 and the
century must be guessed.
The only approach I know of is to try the formats you expect until you
find one that works. Mark Pilgrim's feedparser has a pretty robust
date parser you might look at; look at the _parse_date() function in
this module:
http://code.google.com/p/feedparser/source/browse/trunk/feedparser/feedparser.py
Kent
More information about the Tutor
mailing list