[Tutor] matching a street address with regular expressions

Alan Gauld alan.gauld at btinternet.com
Thu Oct 4 09:34:25 CEST 2007

"Christopher Spears" <cspears2002 at yahoo.com> 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.  Any
> hints?

Yes, don't go too far.

Matching addresses is a fantastically difficult thing 
to do perfectly. There are several companies whose 
only product is software to match and check addresses
and they sell it for hundreds of thousands of dollars 
a license! They spend years developing and improving it.
Our suppllier is up to version 16 and they only release 
new versions every 2 years...

Of course they are matching formats from countries 
around the world and providing GUI management consoles 
and MIS reports etc etc. But the core function of correctly 
identifying valid addresses remains a hugely complex task.

Its a good idea to try just enough of it to realise how hard 
it is. Then stop. :-)


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list