zouzhe0
private static final Pattern MOBILE_PATTERN =
            Pattern.compile("^13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|17[0-9]{9}$|18[0-9]{9}$|19[0-9]{9}$");
private static Pattern isNumericPattern = Pattern.compile("^[-\\+]?[\\d]*$");
public static boolean isMobile(String number) { return MOBILE_PATTERN.matcher(number).matches(); }
public static boolean isNumeric(String str) {
return isNumericPattern.matcher(str).matches();
}
 
public static String mosaicAlipayName(String withdrawName) {
        if (DataUtils.isMobile(withdrawName)) {
            return DataUtils.hidePhoneNum(StringUtils.isBlank(withdrawName) ? "" : withdrawName);
        } else if(isNumeric(withdrawName)) {
            //银行卡号
            String regex = "(\\w{4})(.*)(\\w{4})";
            Matcher m = Pattern.compile(regex).matcher(withdrawName);
            if (m.find()) {
                String rep = m.group(2);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < rep.length(); i++) {
                    sb.append("*");
                }
                return withdrawName.replaceAll(rep, sb.toString());
            }
        }

        return withdrawName.replaceAll("(^\\w)[^@]*(@.*$)", "$1****$2");

    }

 

分类:

技术点:

相关文章:

  • 2021-10-17
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-12-03
  • 2021-08-06
  • 2022-01-06
猜你喜欢
  • 2021-10-06
  • 2022-12-23
  • 2021-11-11
  • 2021-12-29
  • 2021-11-17
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案