js过滤(去除)富文本编辑器中的html标签和换行回车等标记的正则表达式

来源:互联网 发布:盯盯软件官方下载 编辑:程序博客网 时间:2024/04/28 03:48

一段这样的Html包裹的文字:

var description="<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>"


要去除html标签,图片,换行,回车等

    description = description.replace(/(\n)/g, "");    description = description.replace(/(\t)/g, "");    description = description.replace(/(\r)/g, "");    description = description.replace(/<\/?[^>]*>/g, "");    description = description.replace(/\s*/g, "");

得到结果:dsfdssdfdsfssadasasdsaddfds


参考http://www.itlead.com.cn/article/html/148/2011-08-16/content-1769.shtml

原创粉丝点击