Java实现去掉空格换行符回车的方法

public static String replace(String str) {
    String destination = "";
    if (str!=null) {
        Pattern p = Pattern.compile("\\s*|\t|\r|\n");
        Matcher m = p.matcher(str);
        destination = m.replaceAll("");
    }
    return destination;
}

猜你喜欢

转载自blog.csdn.net/qq_33537022/article/details/82887761