📜  地址正则表达式 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:22.450000             🧑  作者: Mango

代码示例2
const address = "One Infinite Loop, Cupertino 95014";
const cityZipCodeRegex = /^[^,\\]+[,\\\s]+(.+?)\s*(\d{5})?$/;
const [_, city, zipCode] = address.match(cityZipCodeRegex) || [];
saveCityZipCode(city, zipCode);