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})

Re: [Tutor] using re groups

2009-03-06 Thread Kent Johnson
On Fri, Mar 6, 2009 at 7:56 AM, ski wrote: > Hello, > I have this: > import re s = "Association of British Travel Agents (ABTA) No. 56542\nAir Travel Organisation Licence (ATOL)\nAppointed Agents of IATA (IATA)\nIncentive Travel & Meet. Association (ITMA)" licenses = re.sp

[Tutor] using re groups

2009-03-06 Thread ski
Hello, I have this: >>> import re >>> s = "Association of British Travel Agents (ABTA) No. 56542\nAir Travel Organisation Licence (ATOL)\nAppointed Agents of IATA (IATA)\nIncentive Travel & Meet. Association (ITMA)" >>> licenses = re.split("\n+", s) >>> licenseRe = re.compile(r'\(([A-Z]+)\)( N

Re: [Tutor] using re to build dictionary

2009-02-24 Thread Norman Khine
Thank you all, this is great. Kent Johnson wrote: On Tue, Feb 24, 2009 at 6:48 AM, Norman Khine wrote: Hello, From my previous post on create dictionary from csv, i have broken the problem further and wanted the lists feedback if it could be done better: s = 'Association of British Travel Ag

Re: [Tutor] using re to build dictionary

2009-02-24 Thread Kent Johnson
On Tue, Feb 24, 2009 at 6:48 AM, Norman Khine wrote: > Hello, > From my previous post on create dictionary from csv, i have broken the > problem further and wanted the lists feedback if it could be done better: > s = 'Association of British Travel Agents (ABTA) No. 56542\nAir Travel Orga

Re: [Tutor] using re to build dictionary

2009-02-24 Thread spir
Le Tue, 24 Feb 2009 12:48:51 +0100, Norman Khine s'exprima ainsi: > Hello, > From my previous post on create dictionary from csv, i have broken the > problem further and wanted the lists feedback if it could be done better: > > >>> s = 'Association of British Travel Agents (ABTA) No. 56542\nA

[Tutor] using re to build dictionary

2009-02-24 Thread Norman Khine
Hello, From my previous post on create dictionary from csv, i have broken the problem further and wanted the lists feedback if it could be done better: >>> s = 'Association of British Travel Agents (ABTA) No. 56542\nAir Travel Organisation Licence (ATOL)\nAppointed Agents of IATA (IATA)\nInce

Re: [Tutor] using re

2007-06-04 Thread Luke Paireepinart
> Thanks for you response. You are correct and I have determined that > something > is wrong with the "self.BackColor == "pink" " statement because it does not > turn the background pink but is firing. > == is comparison, not assignment. Perhaps this is the problem? -Luke __

Re: [Tutor] using re

2007-06-04 Thread johnf
On Monday 04 June 2007 03:10, you wrote: > johnf wrote: > > I have the following > > pattern='^([0-9]{0,%s})(\.[0-9]{0,%s})?$' % (self.IntegerWidth, > > self.DecimalWidth) > > You should use a raw string (prefix with r) to define pattern, though > that isn't the problem here. > > > ) > > if re.

Re: [Tutor] using re

2007-06-04 Thread Kent Johnson
johnf wrote: > I have the following > pattern='^([0-9]{0,%s})(\.[0-9]{0,%s})?$' % (self.IntegerWidth, > self.DecimalWidth) You should use a raw string (prefix with r) to define pattern, though that isn't the problem here. > ) > if re.match(pattern, self.GetValue())==None: > self

Re: [Tutor] using re

2007-06-04 Thread Roel Schroeven
johnf schreef: > I have the following > pattern='^([0-9]{0,%s})(\.[0-9]{0,%s})?$' % (self.IntegerWidth, > self.DecimalWidth) > ) > if re.match(pattern, self.GetValue())==None: > self.BackColor == "pink" > else: > self.BackColor == "white" > > self.IntegerWidth = 2

[Tutor] using re

2007-06-03 Thread johnf
I have the following pattern='^([0-9]{0,%s})(\.[0-9]{0,%s})?$' % (self.IntegerWidth, self.DecimalWidth) ) if re.match(pattern, self.GetValue())==None: self.BackColor == "pink" else: self.BackColor == "white" self.IntegerWidth = 2 self.DecimalWidth=2 the pr