我使用下面的正则表达式替换两个单词之间的文本。它有效,只是它跳过了其中一些。下面粘贴的是一个示例。
var EditedHtml = Regex.Replace(htmlText, @"<script(.*?)</script>", "");
html文本:
<head>
<script src=" https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
<script src="/AspellWeb/v2/js/dragiframe.js" type="text/javascript"></script>
<script type="text/javascript">
var applicationName = '/';
FullPath = (applicationName.length > 1) ? 'http://localhost:65355' + applicationName : 'http://localhost:65355';
//FullPath = 'http://localhost:65355';
GetPath = function (url) {
return FullPath + url;
}
</script>
<script type="text/javascript" src="../../Scripts/stats.js?"></script>
</head>
<body>
.......
<script type="text/javascript">
function loadAndInit() {
$(".dvloading").hide();
if ($.browser.mozilla) {
if (location.pathname == "/Stats/Reports") { // This is for local env.
$("#prntCss").attr("href", "../../../Content/SitePrint_FF.css");
}
else { // This is for DEV/QA/STAGE/PROD env.
$("#prntCss").attr("href", "../../Content/SitePrint_FF.css");
}
}
}
</script>
</body>
编辑的HTML:
<head>
<script type="text/javascript">
var applicationName = '/';
FullPath = (applicationName.length > 1) ? 'http://localhost:65355' + applicationName : 'http://localhost:65355';
//FullPath = 'http://localhost:65355';
GetPath = function (url) {
return FullPath + url;
}
</script>
</head>
<body>
.......
<script type="text/javascript">
function loadAndInit() {
$(".dvloading").hide();
if ($.browser.mozilla) {
if (location.pathname == "/Stats/Reports") { // This is for local env.
$("#prntCss").attr("href", "../../../Content/SitePrint_FF.css");
}
else { // This is for DEV/QA/STAGE/PROD env.
$("#prntCss").attr("href", "../../Content/SitePrint_FF.css");
}
}
}
</script>
</body>