On Tue, 18 Aug 2009 10:52:41 +0200, Gilles Ganault <nos...@nospam.com>
wrote:

>I find it odd that the regex library can't handle European characters
>:-/

Ha, found it! :-)

http://www.regular-expressions.info/python.html

=========
# -*- coding: latin-1 -*-

import locale
import re

locale.setlocale(locale.LC_ALL, 'FR')

re_inscription =
re.compile(r"(?P<date>\d+)\s+(?P<month>\w+)\s+(?P<year>\d+)",re.LOCALE)

dateinscription = "11 Août 2008"
        
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 "Yuck"
=========

Thanks everyone!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to