金狮镖局 Design By www.egabc.com
js 如何正则匹配没有内容的空标签并移除掉"htmlcode">
html='<div id="fixedTools" class="hidden-xs hidden-sm">'+ '\n <a id="backtop" class="hidden border-bottom" href="#" rel="external nofollow" ></a>'+ '\n'+ '\n <div class="qrcodeWraper">'+ '\n <a href="/app#qrcode" rel="external nofollow" ><span class="glyphicon glyphicon-qrcode"></span></a>'+ '\n <img id="qrcode" class="border" alt="sf-wechat" src="/UploadFiles/2021-04-02/appQrcode.png">如果考虑将没有style的span去掉
有span的就留下来
因为默认编辑器中,span没有样式的没有必要
str=str.replace(/<span\s*"$1");
先看下面的位置
零宽断言
接下来的四个用于查找在某些内容(但并不包括这些内容)之前或之后的东西,也就是说它们像\b,^,$那样用于指定一个位置,这个位置应该满足一定的条件(即断言),因此它们也被称为零宽断言。最好还是拿例子来说明吧:断言用来声明一个应该为真的事实。正则表达式中只有当断言为真时才会继续进行匹配。
("htmlcode">
//加强替换主要是考虑多个br的问题 function doRepAdvance(s){ var str=s.replace(/<p><br type="_moz">\s*""); str=str.replace(/<p>\s*<br type="_moz">\s*<\/p>/ig, ""); str=str.replace(/<p>\s*""); str=str.replace(/<p>(\s|\ \;| | |\xc2\xa0)*<\/p>/ig, ""); str=str.replace(/<p>\s*""); str=str.replace(/<p> <\/p>/ig,""); str=str.replace(/<br type="_moz">\n <\/p>/ig, "</p>"); str=str.replace(/<br type="_moz">\s*"</p>"); str=str.replace(/<br\s"</p>"); str=str.replace(/<br \/>\n <\/p>/ig, "</p>"); str=str.replace(/<br>\n <\/p>/ig, "</p>"); //多个br str=str.replace(/(<br type="_moz">\s*)+<\/p>/ig, "</p>"); str=str.replace(/(<br\s"</p>"); //空标签 str=str.replace(/<p style=["'].[^<>]*["']>/ig, "<p>"); str=str.replace(/<span style="background-color: initial;">/ig, "<span>"); //没有style的span去掉 str=str.replace(/<span\s*"$1"); str=str.replace(/<([a-z]+""); //str=str.replace(/<([a-z]+""); return str; }上面都是一些好东西,具体的自己研究吧。
标签:
js正则空标签
金狮镖局 Design By www.egabc.com
金狮镖局
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
金狮镖局 Design By www.egabc.com
暂无js通过正则匹配没有内容的空标签的评论...
更新日志
2024年09月23日
2024年09月23日
- 周冰倩1995《沧桑情歌》JVC日本录制[WAV+CUE]
- 辛禄乐队.2024-热烈的少年【星辰】【FLAC分轨】
- 成龙.1996-龙的心【滚石】【WAV+CUE】
- 童安格.1991-一世情缘【宝丽金】【WAV+CUE】
- 韩红2010-擦肩而过[央金玛][WAV+CUE]
- RiccardoTesi-UnballoLiscio,Vol.II(2024)[24-48]FLAC
- 金池VS刘罡2009《双声情》[WAV+CUE]
- 冯奥迪《卄》[320K/MP3][67.08MB]
- 冯奥迪《卄》[FLAC/分轨][172.46MB]
- Merryland《Merryland》[320K/MP3][69.48MB]
- 苏芮.1991-停在我心里的温柔【福茂】【WAV+CUE】
- 苏慧伦.2020-面面Every.Side.of.Me【相信音乐】【WAV+CUE】
- 群星.1991-不一样的感觉REMIX【宝丽金】【WAV+CUE】
- 银霞.1983-《你那好冷的小手》珍藏纪念版[WAV分轨]
- 银霞.2002-《国语巨星专辑VOL.3》2CD台湾版[WAV+CUE]