java【参考】手机号身份证号脱敏

String phoneNumber = String.valueOf("18866666666").replace("null", "");
phoneNumber = phoneNumber.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.println(phoneNumber);
String identityCardNum = String.valueOf("************").replace("null", "");
identityCardNum = identityCardNum.replaceAll("(?<=\\w{5})\\w(?=\\w{2})", "*");
System.out.println(identityCardNum)um);

 

你可能感兴趣的:(Java,Java,参考,手机号身份证号脱敏)