tytalk-builder
Version:
一个帮助开发者快速构建属于自己的聊天机器人的开源SDK。
17 lines (16 loc) • 434 B
JavaScript
/**
* Created by hfy on 18/6/29.
*/
/**
* 判断string是否为手机号码,或者是否包含手机号码
* @param string
* @returns {boolean}
*/
function isTelephone (string) {
const telephone = string.replace(/[^0-9]/ig,"").match(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/)
if (telephone && telephone.length) {
return telephone[0]
}
return false
}
exports.isTelephone = isTelephone