String tel = "18304072984";
// 括号表示组,被替换的部分$n表示第n组的内容
tel = tel.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.print(tel); // output: 183****2984
转载于:https://www.cnblogs.com/liw66/p/10278402.html
String tel = "18304072984";
// 括号表示组,被替换的部分$n表示第n组的内容
tel = tel.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.print(tel); // output: 183****2984
转载于:https://www.cnblogs.com/liw66/p/10278402.html