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

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 草泥马

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理