简体   繁体   English

在 Notepad++ 中去除 html 注释并只留下代码的代码

[英]Code to strip html comments in Notepad++ and leave only code

I would like to strip HTML comments in Notepad++ and leave only code in an html file.我想在 Notepad++ 中去除 HTML 注释,只在 html 文件中留下代码。 How do I go about this?我该怎么做? I can use regular expression search/replace.我可以使用正则表达式搜索/替换。

I would use我会用

<!--([^-]|-[^-])*-->

which is more robust (less permissive) than Oscar's solution.这比奥斯卡的解决方案更强大(更宽松)。

After searching I couldn't find a simple solution , but then i created one that i would like to share.搜索后我找不到一个简单的解决方案,但后来我创建了一个我想分享的解决方案。

in Select "Regular Expression" - Replace With field empty like this在选择“正则表达式” - 像这样替换为空字段

图片

and that's it!.就是这样!。 You need to carefully and inspect before and after so, not to loose actual code.I did not loose any code.你需要仔细检查前后,不要丢失实际代码。我没有丢失任何代码。

i hope it helps我希望它有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM