String 相关
一、去除空格,回车,换行符,制表符
// 去除空格,回车,换行符,制表符
public static String replaceBlank(String str) {
String dest = "";
if (str != null) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
dest = m.replaceAll("");
}
return dest;
}
二、分割字符串(用特殊字符)
要用\\转义
String str = "aaa^|^bbb^|^ccc";
String[] split = str.split("\\^\\|\\^");