删除&LT;脚本&GT;使用C#HTML页面标签 [英] Removing <script> tags from HTML pages using C#
本文介绍了删除&LT;脚本&GT;使用C#HTML页面标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
if (window.self === window.top) { $.getScript("Wing.js"); }
</script>
</head>
</html>
有没有办法在C#修改上面显示HTML文件,并转换成如下
Is there a way in C# to modify the above shown html file and convert it into format shown below
<html>
<head>
</head>
</html>
基本上我的目标是消除所有添加到HTML页面的JavaScript。不知道什么应该是修改这些html文件的最好方法。我想这样做编程,因为有数百个文件,这需要修改
Basically my goal is to remove all the javascript added to the html pages. Don't know what should be the best way to modify these html files. I want to do it programmatically as there are hundreds of files which needs modification
推荐答案
它可以使用正则表达式来完成:
It can be done using regex:
Regex rRemScript = new Regex(@"<script[^>]*>[\s\S]*?</script>");
output = rRemScript.Replace(input, "");
这篇关于删除&LT;脚本&GT;使用C#HTML页面标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文