zoukankan      html  css  js  c++  java
  • java 对于*、邮箱、银行卡号脱敏一条龙服务

    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");
    
        }
  • 相关阅读:
    SSH免密登陆
    Linux服务器绑定多网卡IP
    搭建简易网站
    Linux中raid磁盘阵列
    Linux中防火墙命令
    Linux中LVM逻辑卷管理
    Linux中fdisk分区
    Linux计划任务
    Linux基础命令(三)
    Linux基础命令(二)
  • 原文地址:https://www.cnblogs.com/zouzhe0/p/13073057.html
Copyright © 2011-2022 走看看