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;
    }

posted on 2013-01-28 13:54  在旅途  阅读(193)  评论(0编辑  收藏  举报

导航