1、去除空格、回车、制表符、换行符

String str = "!!!?    ?1234!!!!??"+"\t"+"abcd!   !!"+"\r"+"!%*)%¥!去除标点符号!"+"\n"+"!,,。 !!..**半角";
System.out.println(str);

String str1 = "";
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
str1 = m.replaceAll("");
System.out.println(str1);

String str2 = "";
str2 = str.replaceAll("\\s*|\t|\r|\n","");
System.out.println(str2);

2、去除标点符号

String str = "!!!?    ?1234!!!!??abcd!   !!!%*)%¥!去除标点符号!!,,。 !!..**半角";
System.out.println(str);

String str1 = "";
str1 = str.replaceAll("[\\pP\\p{Punct}]","");
System.out.println(str1);

String str2 = "";
str2 = str.replaceAll("[\\pP]","");
System.out.println(str2);

String str3 = "";
str3 = str.replaceAll("[\\p{P}]","");
System.out.println(str3);

参考:
1、java去除字符串中的空格、回车、换行符、制表符 2、java 正则表达式去除标点符号