public static String getStringNoBlank(String str) {
if(str!=null && !"".equals(str)) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
String strNoBlank = m.replaceAll("");
return strNoBlank;
}else {
return str;
}
}
也可以直接用笨方法,
str.replaceAll(,);
/* 注:\n 回车(\u000a) ,\t 水平制表符(\u0009) ,\s 空格(\u0008) ,\r 换行(\u000d)*/
原文链接:https://blog.csdn.net/neuqxzy/article/details/42121615
文章评论