- String repl = "";
- if (str!=null) {
- Pattern p = Pattern.compile("\\s*|\t|\r|\n");
- Matcher m = p.matcher(str);
- repl = m.replaceAll("");
- }
- 原文地址:http://blog.csdn.net/zhangzehai2234/article/details/53525598
\t 空格 ('\u0009')
\n 换行 ('\u000A')
\r 回车 ('\u000D')
\d 数字等价于[0-9]
\D 非数字等价于[^0-9]
\s 空白符号 [\t\n\x0B\f\r]
\S 非空白符号 [^\t\n\x0B\f\r]
\w 单独字符 [a-zA-Z_0-9]
\W 非单独字符 [^a-zA-Z_0-9]
\f 换页符
\e Escape