开发者

Javascript regex to match html comments, excluding those inside <style> tags

I need to get html comments ( <!-- --> ) except for those inside tags, which are used sometimes.

<style type="text/css">
<!--
.test { font-size: 12px; }
-->
</style>

Getting html comments is quite easy with this regex:开发者_如何学C

/<!--[^>]*-->/gi

The issue is that i can't exclude those that are inside tags. I tried:

(?!<style[^>]>)

but it still get the html comment. Any ideas?

Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜