if(content==null) return ""
String html = content
// html = html.replace( "'", "&apos")
html = html.replaceAll( "&", "&amp")
html = html.replace( "\"", "&quot") //"
html = html.replace( "\t", "&nbsp&nbsp")// 替换跳格
html = html.replace( " ", "&nbsp")// 替换空格
html = html.replace("<", "&lt")
html = html.replaceAll( ">", "&gt")
return html
}
使用正则表达式即可解决; 例如转义字符\r\n 就只需要如下 *** 作即可: String str = "\r\n"str = str.replaceAll("\r\n","\\r\\n")欢迎分享,转载请注明来源:内存溢出
评论列表(0条)