public static void main(String[] args) throws IOException {
String str="暴力,河岸。";
String r="[^/u4e00-/u9fa5]";
str=str.replaceAll(r,"");
System.out.println(str);
String regEx="暴力|色情"; //表示a或f
Pattern p=Pattern.compile(regEx);
Matcher m=p.matcher(str);
boolean result=m.find();
System.out.println(result);
}
字符串过滤,字符串替换(正则表达式中)去掉字符串中的非中文
最新推荐文章于 2020-02-07 11:43:54 发布