java去除字符串中的空格、回车、换行符、制表符
package cmd;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RuntimeTest {
public static void main(String[] args) {
String str = "sdfs sdf\r\ndf dfdfd\taa";
System.out.println(str);
Pattern pattern = Pattern.compile("\\s*|\r|\n|\t"); \\s 空格;\r 换行;\n 回车;\t 水平制表符
Matcher matcher =pattern.matcher(str);
str =matcher.replaceAll("");
System.out.println(str);
}
}