Mysql:
select REPLACE(idcard, SUBSTR(mobile,4,12), '************') idcard from sys_users
select insert(idcard,4, 12, '*************') idcard from sys_users ;
java code:
1, it may be 18 or ID 15
if (newTBProjectCorpInfo.getPersonidcard().length() == 18) {
newTBProjectCorpInfo.setPersonidcard(newTBProjectCorpInfo.getPersonidcard().replaceAll("(\\d{4})\\d{10}(\\d{4})", "$1****$2"));
} else if (newTBProjectCorpInfo.getPersonidcard().length() == 15) {
newTBProjectCorpInfo.setPersonidcard(newTBProjectCorpInfo.getPersonidcard().replaceAll("(\\d{4})\\d{8}(\\d{4})", "$1****$2"));
}
2, I like to use this
newTBProjectCorpInfo.setPersonidcard(newTBProjectCorpInfo.getPersonidcard().replaceAll("(\\w{4})\\w{0,}(\\w{4})", "$1****$2"));
Sometimes treatment may need to be ID card, military ID, passport, identity card Taiwan, Hong Kong permanent identity card and other data directly to the middle portion of the hide.
ID card |
Military officer |
passport |
Taiwan identity card |
Hong Kong Permanent Identity Card |
Jing Guanzheng |
other |