正则过滤标签

1、删除a标签与span标签
str = str.replace(/(<\/?a.*?>)|(<\/?span.*?>)/g, '');

2、过滤删除style属性
str = str.replace(/style\s*?=\s*?(['"])[\s\S]*?\1/g, "$1");

3、去除行尾空白
str = str.replace(/[ | ]*\n/g, "\n");
posted @ 2020-04-22 18:06  CatherLee  阅读(146)  评论(0编辑  收藏  举报