regex match address

Solutions on MaxInterview for regex match address by the best coders in the world

showing results for - "regex match address"
Riccardo
04 Sep 2016
1const address = "One Infinite Loop, Cupertino 95014";
2const cityZipCodeRegex = /^[^,\\]+[,\\\s]+(.+?)\s*(\d{5})?$/;
3const [_, city, zipCode] = address.match(cityZipCodeRegex) || [];
4saveCityZipCode(city, zipCode);
5