<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> JS过滤(去除)富文本编辑器中的html标签和换行回车等标记的正则表达式</title>
<script language="javascript">
function show(){
var test="<p>\n\t<img src=\"http://localhost/Scripts/KindEditor/Editor/plugins/emoticons/images/0.gif\" alt=\"\" border=\"0\" />ds<em>fds</em>\n</p>\n<p>\n\ts<span style=\"font-size:16px;\">dfd</span>sf<img src=\"http://localhost/Scripts/KindEditor/Editor/plugins/emoticons/images/19.gif\" alt=\"\" border=\"0\" />ds<strong>fdsfds</strong>\n</p>\n<p>\n\t<br />\n<strong></strong>\n</p>\n<p align=\"center\">\n\t<strong>d<span style=\"font-family:FangSong_GB2312;\">ssa</span>dasasdsad<u>dfds</u><br />\n</strong>\n</p>"
test = test.replace(/(\n)/g, "");
test = test.replace(/(\t)/g, "");
test = test.replace(/(\r)/g, "");
test = test.replace(/<\/?[^>]*>/g, "");
test = test.replace(/\s*/g, "");
document.getElementById("sd").innerHTML=test;
}
</script>
</head>
<body οnlοad="show();">
<div id="sd"></div>
</body>
</body>
</html>
更多推荐
JS过滤(去除)富文本编辑器中的HTML标签和换行回车等标记的正则表达式
发布评论