android 手机号码隐藏其中4位

    public static String mobileEncrypt(String mobile) {
    
    
        final String PHONE_BLUR_REGEX = "(\\d{3})\\d{4}(\\d{4})";
        /** * 手机号脱敏替换正则 */
        final String PHONE_BLUR_REPLACE_REGEX = "$1****$2";
        /** * 手机号格式校验 * @param phone * @return */
        if (mobile.isEmpty() || (mobile.length() != 11)) {
    
    
            return mobile;
        }
        return mobile.replaceAll(PHONE_BLUR_REGEX, PHONE_BLUR_REPLACE_REGEX);
    }

猜你喜欢

转载自blog.csdn.net/weixin_37077736/article/details/126050036