Java 特殊字符正则替换
2021-04-12 12:25
标签:replace print match void 特殊字符 style acea mat row Java 特殊字符正则替换 标签:replace print match void 特殊字符 style acea mat row 原文地址:https://www.cnblogs.com/lshan/p/13354335.html @Test
public void testRegex() throws Exception {
String str="das:! $%#*(*(";
String regEx = "[`~!@#$%^&*()+=|{}‘:;‘\\[\\]./?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
boolean isfind = m.find();
System.err.println(isfind);
//regex
String replaceAll = str.replaceAll(regEx, "");
System.out.println(replaceAll);
}