Re: [Tutor] using re to match text and extract info

2010-01-01 Thread Norman Khine
Thank you for the replies and Happy New Year! On Thu, Dec 31, 2009 at 7:19 PM, Dave Angel wrote: > Norman Khine wrote: >> >> hello, >> >> > > import re > line = "ALSACE 67000 Strasbourg 24 rue de la Division Leclerc 03 88 23 > 05 66 strasbo...@artisansdumonde.org" > m = re.sea

Re: [Tutor] using re to match text and extract info

2009-12-31 Thread Dave Angel
Norman Khine wrote: hello, import re line = "ALSACE 67000 Strasbourg 24 rue de la Division Leclerc 03 88 23 05 66 strasbo...@artisansdumonde.org" m = re.search('[\w\-][\w\-\...@[\w\-][\w\-\.]+[a-za-z]{1,4}', line) emailAddress .search(r"(\d+)", line) phoneNumber = re.compile(r'(\d{2}) (\d{2

Re: [Tutor] using re to match text and extract info

2009-12-31 Thread Emmanuel Ruellan
What's wrong with the phone number? >>> phoneNumber.search(line).groups() ('03', '88', '23', '05', '66') This looks fine to me. Here is a regex that splits the line into several named groups. Test it with other strings, though >>> line = "ALSACE 67000 Strasbourg 24 rue de la Division Leclerc 03

[Tutor] using re to match text and extract info

2009-12-31 Thread Norman Khine
hello, >>> import re >>> line = "ALSACE 67000 Strasbourg 24 rue de la Division Leclerc 03 88 23 05 >>> 66 strasbo...@artisansdumonde.org" >>> m = re.search('[\w\-][\w\-\...@[\w\-][\w\-\.]+[a-za-z]{1,4}', line) >>> emailAddress .search(r"(\d+)", line) >>> phoneNumber = re.compile(r'(\d{2}) (\d{2})