4 ms·
"You are expecting the data in "City, State" format" This is a bad assumption. What you should do is throw away commas, split along whitespace, and then see if
by bena 15y ago
"You are expecting the data in "City, State" format"
This is a bad assumption. What you should do is throw away commas, split along whitespace, and then see if the last element split is a valid state or territory.
Because some lazy guy will type "new orleans la" and just ruin your day.
- masterzora 15y agoAnd then some non-lazy guy types in Albuquerque New Mexico and you find that Mexico is not a US State. I know, this isn't a particularly difficult thing to work around, but I was amused that you replaced one bad assumption with another.
- bena 15y agoOh well, getting closer. ;) We could always start taking from the back and doing look ups until we have a match or we finish the string.
- pavel_lishin 15y agoDallas, TX, 75254. Is "." a state? How about "75254"?