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