自己整理的 [正则表达式] [JS相关的正则函数]
replace的方案
javascript
let phonenumber = number.replace(number.phonenumber.substring(3,7), '****')
let phonenumber = number.replace(number.phonenumber.substring(3,7), '****')
js
// 方法1
var phone = '18801333333';
var reg = /^(\d{3})\d{4}(\d{4})/;
var newPhone = phone.replace(reg,'$1****$2');
console.log(newPhone);
// 方法2
let phonenumber = number.replace(number.phonenumber.substring(3,7), '****')
// 方法1
var phone = '18801333333';
var reg = /^(\d{3})\d{4}(\d{4})/;
var newPhone = phone.replace(reg,'$1****$2');
console.log(newPhone);
// 方法2
let phonenumber = number.replace(number.phonenumber.substring(3,7), '****')