代码如下:
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
strReplaced = m.replaceAll("");
注释:
\n:回车
\t:水平制表符
\r:换行
\s:空格
代码如下:
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
strReplaced = m.replaceAll("");
注释:
\n:回车
\t:水平制表符
\r:换行
\s:空格