对手机号或者邮箱中间的部分进行****替换

 
const ref = /(.{5}).+(.{2}.+)/g;
number = str.replace(ref,"$1****$2");
console.log(number)
 
const ref = /(.{1}).+(.{2}@.+)/g;
email =str.replace(ref,"$1****$2");
 
原文地址:https://www.cnblogs.com/lr-blog/p/9075770.html