手机号方法一:
const phone ="13623021456"
const phone2 = phone.replace(/^(.{3}).+(.{4})$/,"$1****$2");
console.log(phone2);
//输出:136****1456
手机号方法二:
const phone = '18801333333';
const reg = /^(\d{3})\d{4}(\d{4})/
const newPhone = phone.replace(reg,'$1****$2');
console.log(newPhone); //188****3333
Vue手机号脱敏:
身份证脱敏:
const idcode ="440883199912056626"
const idcode2 =idcode.replace(/^(.{4}).+(.{4})$/,"$1****$2");
console.log(idcode2); //4408****6626