I need to pull the city and state out string of data that look as follows:
8 mi SSW of Newtown, PA
10 mi SE of Milwaukee, WI
29 Miles E of Orlando, FL
As of right now I am passing each string individually into a method
string statusLocation = "8 mi SSW of Newtown, PA"
etc. one at a time.
What would be the best way to search this string for the city state? I was thinking either regex or substring and index of the comma etc. I wasn’t quite sure what kind of issues I would run into if a state is 3 characters or a city has a comma in it because this is Canada data as well and I am not sure how they abbreviate stuff.
You could do a
parts then looks like this: { “8”, “mi”, “SSW”, “of”, “Newtown, PA” }, and you can access the “Newtown, PA” easily with parts[4].