java替换ascii表字符

时间:2023-11-19 19:42:44

如下:

    //处理特殊字符
    public String dealSpecialXml(String xml){
        String result = "";
        //result = xml.replaceAll("", "");
        result = xml.replaceAll("[\\x01-\\x1f]", "");
//        String value = null;
//        Pattern p = Pattern.compile("[\\x01-\\x1f]");
//        Matcher m = p.matcher(xml);
//      result = m.replaceAll("");
        //result = HtmlUtils.htmlEscape(result);
        return result;
    }