替換 html中換行符、空格 ;去除字串中的空格\\s*,回車\n,換行符\r,製表符\t
阿新 • • 發佈:2019-01-28
1、替換 html中換行符、空格
/** 替換 html中換行符、空格 */
public static String repText(String str) throws Exception { String r = ""; r = str.replaceAll("<br/>", "\n"); r = r.replaceAll(" ", " "); return r; }
2、去除字串中的空格\\s*,回車\n,換行符\r,製表符\t
public static String isReplaceStr(String str_content) { String r = ""; Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str_content); r = m.replaceAll(""); return r; }