编程语言
首页 > 编程语言> > Java把换行符空格置位符换成空字符

Java把换行符空格置位符换成空字符

作者:互联网

 

json转换报错

cn.hutool.json.JSONException: Unterminated string at 396 [character 0 line 2]

可以试试把json里面的置位符更换成空字符

 

    public static String replaceWithBlank(String str){
        Pattern p = Pattern.compile("\\s*|\t|\r|\n");
        Matcher m = p.matcher(str);
        String finishedReplaceStr = m.replaceAll("");
        return finishedReplaceStr;
    }

 

标签:Java,置位,Pattern,finishedReplaceStr,空字符,json,str,String
来源: https://www.cnblogs.com/shisanye/p/15761817.html