I have a string such as
397 Walker Road Wayne, PA 19087
I need to extract the address information (street address, city, state, zip) from it. The problem is, the amount of white space is not consistent in the database.
I’ve split the string on the comma, and extracted the state and zip. But am at a loss on how to get the city out of there, especially since the white space is inconsistent.
You can remove extra whitespaces using regular expression like
[\s]{2,}which means find 2 or more consecutive whitespaces. This regex wont match single whitespace. You can then replace matched whitespaces with blank and then extract the city (extracting city is different problem). Hope this helps.