R
R
resident2014-09-18 22:30:30
PHP
resident, 2014-09-18 22:30:30

How to parse an address string into components?

Hello! I have a list of addresses like this:

Адрес: Anya Demko 21 Haynes Street East Boston, MA 02128 United States
Адрес: Arnold Chun 4P, Portman Mansion Chiltern Street London, London  W1U 6NS United Kingdom
Адрес: Deborah Arnoldy 15401 White Ave. Allen Park, MI 48101 United States
Адрес: Ramakanth k H no 10 -3-30 Fathenagar Hyderabad, Andhra Pradesh  500018 India
Адрес: Arthur Doorgeest van Boeijenplantsoen 20 2253WS Voorschoten Netherlands
Адрес: Arunas Kazlauskas Asigalio g. 27-25 Kaunas, lithuania  lt-49149 Lithuania
Адрес: Michelle Green Unit 2 79  Hawthorne Rd   Hawthorne, QLD 4171 Australia

How to parse it to get city, state/region, zip and country? Not a single obvious option comes to mind, because. There are no separators, only spaces.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KorsaR-ZN, 2014-09-18
@resident

Either use the dictionary to pull out the necessary data., i.e. find the base, Shatov, cities, zip, etc., and use it to make a selection from the lines.
Or try to search through the google places api, i.e. it’s obvious that the first two words are the name, we insert them, then we feed the string into the api, and we get the data as needed, for the provided data the second option worked well, for the rest if She's the same, so she'll be fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question