Java处理关键字进行脱敏操作
1、通过表头获取需要处理的下标列
注:此处导出表格时对关键字进行脱敏处理
/**
* .
* 对表头进行过滤判断
*
* @param headers 表头
* @return 对应的下标列及方法名
*/
public static Map<String, String> headsFilter(String[] headers) {
Map<String, String> indexItem = new HashMap<>();
int index = 0;//具体下标
for (String word : headers) {
if (word.matches("((?=.*证号)|(?=.*身份证)|(?=.*护照号码)|(?=.*客户号)|(?=.*证件号码))^.*$")) {
indexItem.put(String.valueOf(index), "maskIdCard");
} else if (word.matches("((?=.*账户)|(?=.*卡号)|(?=.*银行卡卡号))^.*$")) {
indexItem.put(String.valueOf(index), "bankCard");
} else if (word.matches("((?=.*址)|(?=.*地址))^.*$")) {
indexItem.put(String.valueOf(index), "address");
} else if (word.matches("((?=.*手机号)|(?=.*主叫号码)|(?=.*被叫号码))^.*$")) {
indexItem.put(String.valueOf(index), "maskPhone");
} else if (word.matches("(?=.*姓名).*$")) {
indexItem.put(String.valueOf(index), "chineseName");
} else if (word.matches("(?=.*固定电话).*$")) {
indexItem.put(String.valueOf(index), "fixedPhone");
} else if (word.matches("(?=.*邮箱).*$")) {
indexItem.put(String.valueOf(index), "email");
}
index++;
}
return indexItem;
}


