Converting DD MM YYYY into YYYY-MM-DD?

Ben Finney ben+python at benfinney.id.au
Tue Aug 18 09:10:50 CEST 2009


Gilles Ganault <nospam at nospam.com> writes:

> Thanks everyone for the help. This script is just a one-shot thingie
> on my work host, not as a web script or anything professional.
>
> On Mon, 17 Aug 2009 17:05:28 -0700 (PDT), Jonathan Gardner
> <jgardner at jonathangardner.net> wrote:
> >    r"(?P<date>\d+)\s+(?P<month>\w+)\s+(?P<year>\d+)"
>
> I've never seen regexes like this. I'm curious to know what those
> mean:

Luckily, you have access to the documentation to find out.

> r = Unicode?

<URL:http://docs.python.org/reference/lexical_analysis.html#string-literals>

> (?P<date> = ? means that it shouldn't be greedy, what about P<date>?

<URL:http://docs.python.org/library/re#regular-expression-syntax>

-- 
 \      “We reserve the right to serve refuse to anyone.” —restaurant, |
  `\                                                             Japan |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list