String mobile = "13099998888";
mobile = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.println(mobile);
输出为
130****8888
String mobile = "13099998888";
mobile = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.println(mobile);
输出为
130****8888