views:

53

answers:

2

Hello,

Does anyone have a recommended pseudo-algorithm for, given a string containing an address:

Break apart the address apart into a Street variable, a City variable, a State variable, and a Zip variable

The address string may be formatted in a number of different ways. For example, it may be comma separated or it may be separated by spaces. Also, the address may only contain a city and state, and not a street address or zip code. Similarly, it may contain a street, city, state, and not a zip code.

To make things harder, I cannot use regular expressions (as I am developing on a mobile platform that does not support it).

Thanks!

A: 

Here is a cool solution using Google Maps provided by John. May be you want to use that :

http://stackoverflow.com/questions/877742/java-postal-address-parser

Ramp
Thanks for the link, Ramp, but unfortunately I cannot use any external web services. I need to do everything locally in my Java code. But Google is definitely awesome at formatting such information...
behrk2
A: 

No, but look at JGeocoder:

http://jgeocoder.sourceforge.net/parser.html

They split addresses up into their constituent parts. You could take a look at the source for that...

Jon
I was just looking at that as we speak, the only problem is that it does use regular expressions. But perhaps I can still use some of its logic.
behrk2