公司名称脱敏方法
代码案例
public static String customerMask(String customerName) {
String res = "";
if(!StringUtils.isEmpty(customerName) && customerName.length()<7){
StringBuilder stringBuilder = new StringBuilder(customerName);
res = stringBuilder.replace(1, customerName.length()-1, "****").toString();
}
if (!StringUtils.isEmpty(customerName) && customerName.length()>=7) {
StringBuilder stringBuilder = new StringBuilder(customerName);
res = stringBuilder.replace(3, customerName.length()-2, "****").toString();
}
return res;
}
效果展示: