const getPhone = (str) => str.replace(/[-\s]/g, '').slice(-11) // 源数据 const repo = [ '+86 18612345678', '8613898765421', '135-1234-5678', '+8615145698763', '+86 151-4569-8763' ] for (const item of repo) { console.log(getPhone(item)) }