tytalk-builder
Version:
一个帮助开发者快速构建属于自己的聊天机器人的开源SDK。
18 lines (16 loc) • 388 B
JavaScript
/**
* Created by hfy on 18/6/29.
*/
/**
* 抽取电话号码
* @param string
* @returns {null}
*/
function extractTelephone (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 null
}
module.exports = extractTelephone