Java替换手机号掩码

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

猜你喜欢

转载自www.cnblogs.com/liw66/p/10278402.html