日期:2014-05-20 浏览次数:20785 次
private String htmlFilter( String line ) { if( line == null || line.equals("") ) { return ""; } // replace ampersands with HTML escape sequence for ampersand; line = replace(line, "&", "&"); // replace \" sequences with HTML escape sequences; line = replace(line, "\\\"", "\""); // replace the \\ with HTML escape sequences. fixes a problem when // backslashes preceed quotes. line = replace(line, "\\\\", "\\" ); // replace less-than signs which might be confused // by HTML as tag angle-brackets; line = replace(line, "<", "<"); // replace greater-than signs which might be confused // by HTML as tag angle-brackets; line = replace(line, ">", ">"); return multiLineCommentFilter(line); }
------解决方案--------------------
./在正则表达式中要转义,但在java字符串中是不需要转义的
String str = "\\\"\\.\\/";
写正则表达式要这样才行