身份证手机号脱敏

 // 手机号码前三后四脱敏
String PHONE = listmap.get("PHONE")+"";
if (StringUtils.isEmpty(PHONE) || (PHONE.length() != 11)) {
    listmap.put("PHONE", PHONE);
}else {
    listmap.put("PHONE", PHONE.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
}

//身份证前三后四脱敏
String IDNO = listmap.get("IDNO")+"";
if (StringUtils.isEmpty(IDNO) || (IDNO.length() < 8)) {
    listmap.put("IDNO", IDNO);
}else {
    listmap.put("IDNO", IDNO.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*"));
}

猜你喜欢

转载自www.cnblogs.com/tianxuwei/p/10478990.html