身份证脱敏处理(业务开发中,有时候身份证需要隐藏一部分)
程序员文章站
2022-08-11 17:30:57
package com.test.TestBoot.SingleModel;import org.springframework.util.StringUtils;public class Test { public static void main(String[] args) { System. ......
package com.test.testboot.singlemodel;
import org.springframework.util.stringutils;
public class test {
public static void main(string[] args) {
system.out.println(idhandle("340826199110142211"));
}
public static string idhandle(string idcardnumber) {
if (stringutils.isempty(idcardnumber) || (idcardnumber.length() < 8)) {
return idcardnumber;
}
return idcardnumber.replaceall("(?<=\\w{3})\\w(?=\\w{4})", "*");
}
}