Re: [Tutor] matching a street address with regular expressions

2007-10-04 Thread Ricardo Aráoz
Christopher Spears wrote: > One of the exercises in Core Python Programming is to > create a regular expression that will match a street > address. Here is one of my attempts. > street = "1180 Bordeaux Drive" patt = "\d+ \w+" import re m = re.match(patt, street) if m is

Re: [Tutor] matching a street address with regular expressions

2007-10-04 Thread Alan Gauld
"Christopher Spears" <[EMAIL PROTECTED]> wrote > create a regular expression that will match a street > address. Here is one of my attempts. > > Obviously, I can just create a pattern "\d+ \w+ \w+". > However, the pattern would be useless if I had a > street name like 3120 De la Cruz Boulevard

Re: [Tutor] matching a street address with regular expressions

2007-10-03 Thread John Fouhy
On 04/10/2007, Christopher Spears <[EMAIL PROTECTED]> wrote: > Obviously, I can just create a pattern "\d+ \w+ \w+". > However, the pattern would be useless if I had a > street name like 3120 De la Cruz Boulevard. Any > hints? Possibly you could create a list of street types ('Street', 'Road', 'C

[Tutor] matching a street address with regular expressions

2007-10-03 Thread Christopher Spears
One of the exercises in Core Python Programming is to create a regular expression that will match a street address. Here is one of my attempts. >>> street = "1180 Bordeaux Drive" >>> patt = "\d+ \w+" >>> import re >>> m = re.match(patt, street) >>> if m is not None: m.group() ... '1180 Bordeaux'