1. 程式人生 > >java 字串脫敏

java 字串脫敏

後臺傳給前段資料時,我們可以將一些敏感資訊脫敏,如身份證手機號碼

/字串脫敏     public String formatToMask(int start ,int end ,String src){         if (StringUtils.isEmpty(src)) {             return "";         }         String regex = "(\\w{"+start+"})(\\w+)(\\w{"+end+"})";         return src.replaceAll(regex, "$1**********$3");   //   *的數量是   src.length -start-end     }