字符串去除所有的空格

Posted 龙芳伟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了字符串去除所有的空格相关的知识,希望对你有一定的参考价值。

 1  private String replaceBlank(String str){
 2     String dest = null;
 3     if(str == null){
 4       return dest;
 5     }else{
 6       Pattern p = Pattern.compile("\\s*|\t|\r|\n");
 7       Matcher m = p.matcher(str);
 8       dest = m.replaceAll("");
 9       return dest;
10     }
11   }

 

以上是关于字符串去除所有的空格的主要内容,如果未能解决你的问题,请参考以下文章