欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-05-26 11:29:14
...
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;
}

原文:https://blog.csdn.net/qq_33537022/article/details/82887761