将手机号中间四位转换为 * 号
时间:2021-03-03 12:03:01
收藏:0
阅读:0
使用正则将手机号中间四位转换为 *
号:
let mobile = "131 0000 8080" function convertMobile(mobile){ const mobileReg = /(\d{3})(\d{4})(\d{4})/ig; let mobileCalc = mobile.replace(/\s+/ig,""); mobileCalc = mobileCalc.replace(mobileReg,"$1****$3"); return mobileCalc; } convertMobile(mobile); //131****8080
来自:https://www.jianshu.com/p/7ef31e4a3587
评论(0)