1. 切割
phone = res.phone.substr(0, 3) + '****' + res.phone.substr(7)
2. 正则
s.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
3. 隐藏邮箱:只显示@前面的首位和末位:
s.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)", "$1****$3$4"))
1. 切割
phone = res.phone.substr(0, 3) + '****' + res.phone.substr(7)
2. 正则
s.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
3. 隐藏邮箱:只显示@前面的首位和末位:
s.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)", "$1****$3$4"))