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',
'Crescent', 'Lane', etc.), then construct a regular expression
matching "a number, followed by one or more words, followed by a
street type".
Another thing you could do: put the street number, street name, and
street type into separate named groups, so you could do things like
"m['number']" to get the street number from the match object.
Finally, street addresses can be very dirty -- you get people writing
things like:
"Flat A, 13 Main St"
"13A Main St"
"13-A Main St"
"13/A Main St"
"13-15 Main St"
and other variations. Some people earn good money doing address cleaning :-)
--
John.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor