<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
<script>
var reg = /[+-\s]/g,
mobileReg = /^(13|15|18)\d{9}$/,
res = [], tempStr;
var phones = [ ' +86 12345678910 ', ' 8613898765421', '135-1234-5678', '+8615145698763', '+86 151-4569-8763']
for (var i = 0; i < phones.length;i++) {
tempStr = phones[i].trim().replace(reg, '').slice(-11);
if (mobileReg.test(tempStr)) {
res.push(tempStr)
}
}
console.log(res);
// ["13898765421", "13512345678", "15145698763", "15145698763"]
转载
https://segmentfault.com/q/1010000002804317
</script>
</html>