@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); }