const content = "我的手機是13123456789,我的電話是022-12345678"
const phone = []
if (content.match(/1(3|4|5|7|8)\d{9}/g) || content.match(/0[0-9]{2,3}-\d{8,9}/g)) {
const arr1 = content.match(/1(3|4|5|7|8)\d{9}/g)
const arr2 = content.match(/0[0-9]{2,3}-\d{8,9}/g)
phone.push(...arr1,...arr2)
}
console.log(phone) // ["13123456789","022-12345678"]
微信小程序開發交流qq羣 829873465
承接微信小程序開發,掃碼加微信