以下の正規表現を使用して、2 つの単語の間のテキストを置き換えます。それらのいくつかをスキップすることを除いて、動作します。以下に貼り付けたのは一例です。
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>
EditedHtml :
<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>