On Tue, 18 Aug 2009 17:10:50 +1000, Ben Finney <ben+pyt...@benfinney.id.au> wrote: >Luckily, you have access to the documentation to find out.
I never used groups before. Thanks for showing me. At this point, the script is almost done, but the regex fails if the month contains accented characters (eg. "Août", but fine if eg. "Jan"). Adding a line to load the French locale doesn't help :-/ Any idea what I could do to keep the regex happy? Thank you. ============== import re import apsw import locale #In case error due to accent in month name, but no soup 4 U locale.setlocale(locale.LC_ALL, 'FR') connection=apsw.Connection("test.sqlite") cursor=connection.cursor() re_inscription = re.compile(r"(?P<date>\d+)\s+(?P<month>\w+)\s+(?P<year>\d+)") sql = 'SELECT id,dateinscription,dateconnexion FROM mytable' rows=list(cursor.execute(sql)) for row in rows: dateinscription = row[1] dateconnexion = row[2] #Prints OK print dateinscription m = re_inscription.search(dateinscription) if m: day = m.group("date") month = m.group("month") year = m.group("year") print "%s-%s-%s" % (year,month,day) else: print "No go" ============== -- http://mail.python.org/mailman/listinfo/python-list