text查询带空格的正则

public static String deleteBlank(String string) {
        Pattern p = Pattern.compile("\\s*|\t|\r|\n");
        Matcher m = p.matcher(string);
        String after = m.replaceAll("");
        return after;
    }
replace("","");
///替换空格为\\空格
  public static String convertBlank(String string) {
        Pattern p = Pattern.compile("\\s");
        Matcher m = p.matcher(string);
        String after = m.replaceAll("\\ ");
        return after;
    }

原文地址:https://www.cnblogs.com/lionfight/p/2879818.html