User input parsing - city / state / zip / country

I am looking for advice on analyzing user input in several City / State / Zip Code / Country combinations.

A common example would be what Google maps do.

Some input examples:

  • "City, State, Country"
  • "City, country"
  • "City, Zip Code, Country"
  • City, State, Zip Code
  • "Postcode"

What will be the effective and correct way to analyze this input from the user?

If you know of any implementation examples, please share :)

+5
source share
4 answers

. ( Map-Reducer), , . ,

  • , , , .
  • ?
  • , .
  • ? , , .

, , . , , , (, Google), .

, , , - Google Yahoo .

+1

, Google . .

, , - , , .. . , , , . , . , , , , , , .

, . - , , 10 , .

, . . - , GoogleMaps, , .

, .

0

, (City Zip State Country), , , , , . , .

Assuming we're talking about US addresses -

  • Zip is most obvious, so check that first.
  • The state has 50x2 options (California or California), check the following.
  • There are ~ 190x2 options in the country, depending on how you want to be (USA, USA, USA).
  • All that remains is probably your City.

In terms of efficiency, it might make sense to check out a few standard formats first, as Dan suggests.

0
source

All Articles