关于springboot:正则表达式过滤掉数字广告

1次阅读

共计 441 个字符,预计需要花费 2 分钟才能阅读完成。

public static String replaceSpecialNumeric(String numeric) {
  // 广告数字的正则
  String regex = "[A-Za-z0-9⓪①②③④⑤⑥⑦⑧⑨⑩零壹贰叁肆伍陆柒捌玖拾⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⒈⒉⒊⒋⒌⒍⒎⒏⒐⒑ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉]{5,}";
  if (StringUtils.isNotBlank(numeric)) {Pattern p = Pattern.compile(regex);
    Matcher matcher = p.matcher(numeric);
    return matcher.replaceAll("*");
  }else {return wechat;}
}

成果:

 public static void main(String[] arg) {String b = replaceSpecialNumeric("ⅥⅦ111 叁 1sss aaa 草泥马");
        System.out.println(b);
    }

控制台打印:

    • aaa 草泥马
正文完
 0