正则判断字符是否包含手机号

字符前后不能是数字,满足手机号标准

String msg ="19009098989";
    String mobliePattern = "((?<!\\d))(mobile|手机号|)(=|=\\[|\\\":\\\"|:|:|='|':'|)(1)([3-9]{1}\\d{1})(\\d{4})(\\d{4})(\\]|\\\"|'|)((?!\\d))";
    String mobileReplace = "$1$2$3$4****$6";
    Pattern regex = attern.compile(mobliePattern);
    Matcher matcher = regex.matcher(msg);
        if (matcher.find()) {
           System.out.println(matcher.replaceAll(mobileReplace));
        }

你可能感兴趣的:(后端)