views:

50

answers:

3

notice that on google maps you can input the address any way you like. as long as it is a valid address...google maps will read it.

In some ruby book I had seen code snippet for something like this, but with phone numbers.

Any ideas how this could be done for addresses?

in language of your choice.

EDIT:

i dont care about a "valid" address. I just want to parse an address. so that 123 fake street, WA, 34223 would be an address and so will 123 fake street WA 34223

A: 

it is not trivial task. first you have to have base of all streets, populated places and may me countries (if you want international look up). then try to find each word from input string in each list and try to find matches for all words.

Andrey
but why do we need that? i dont care about a "valid" address. I just want to parse an address. so that 123 fake street, WA, 34223 would be an address and so will 123 fake street WA 34223
ratan
i'll explain. you mentioned google. google can parse both those addresses:224 W 30th St, New York, NY 10001, USAandNew York 224 W 30th St NY 10001, USAgoogle knows that they are same. do you want to achive same result?
Andrey
sounds like that he is more interested in the regex aspect rather than if the address is correct
drake
A: 

You could create a regular expression that would match each format you want to accept. When one of them matches, you will know how to parse that particular string. If you think about it, there probably aren't more than 10 common formats people will use to type out an address 99.9% of the time.

SP
A: 

You can find a commercial solution for this on address-parser.com

Mike Warner