I use the below regex to replace text between two words. It works, except that it skips some of them. Pasted below is an example.
var EditedHtml = Regex.Replace(htmlText, @"<script(.*?)</script>", "");
htmlText :
<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>