I'm looking to put together a basic validation for a U.S. city. The criteria would be that alpha characters, spaces, periods, hyphens, and apostrophes are allowed, with nothing else. So the following would be allowed:
Saint Louis
St. Louis
Washington D.C.
O'Hara (do any US cities exist with apostrophes?)
Raleigh-Durham
I've started this:
$regex = "^[[:alpha:][:space:]/.-]*$";
However, it still allows for anything that is allowed to trail the subject, ie. "St. Louis." is allowed.
What's the best way to prevent this?
Otherwise, is there a better way to handle a valid city name?