setbug

使用正则将手机号中间四位转换为 * 号:

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

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2021-11-27
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-11-27
  • 2021-11-27
  • 2021-12-11
相关资源
相似解决方案