Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62663

Re: How to check the date validity?

References <CA+FnnTxf1te0s4fmaXfP1wcCQ8esxrfyx3TN-JKizrMTyL-Lsg@mail.gmail.com>
Date 2013-12-23 19:39 -0700
Subject Re: How to check the date validity?
From Jason Friedman <jsf80238@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4583.1387854401.18130.python-list@python.org> (permalink)

Show all headers | View raw


> In this file I have 3 different kind of fields: one consist of the
> sole date, one - sole time and one - datetime. The time includes
> milliseconds, i.e. "12:55:55.705"
> All fields of the file including those 3 I am reading as the string.
> All those strings after validating will go into mySQL table.

> I tried to do an RE, but its static validation and so will not work in
> all cases.

Not sure what you mean by static validation.  Would this not work?
import re
if re.search(r"\d{1,2}:\d{2}:\d{2}(.\d{1,3})?", "12:55:55.705"):
    # It's a time

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to check the date validity? Jason Friedman <jsf80238@gmail.com> - 2013-12-23 19:39 -0700

csiph-web