[Tutor] matching a street address with regular expressions
nagle at animats.com
Fri Oct 12 06:50:12 CEST 2007
Shawn Milochik wrote:
> On 10/4/07, Ricardo Aráoz <ricaraoz at gmail.com> wrote:
>> 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.
This is actually quite difficult to do well. Worse,
regular expressions are the wrong tool for the job,
because addresses are properly parsed in reverse, from the END of
the address. See the USPS Postal Address Standards at
worth reading is "Frank's Compulsive Guide to Postal Addresses"
Here's a fun exercise: convert this address parser in Perl
There are features in those regular expressions that I can't find in three
Perl books or the online documentation.
If anyone has a first-rate address parser in Python that will cover
most of the developed world, I'd like to talk to them.
More information about the Python-list