假设我在我的aspx页面中编写了我的javascript,如下所示
<script type="text/javascript">
function pop() {
// test 1
/* test1
test2
test3
*/
myfunc1();
myfunc1();
myfunc1();
}
现在在运行时我想从页面的渲染方法中使用正则表达式从页面中删除所有javascript注释。所以告诉我我需要使用什么样的正则表达式。
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
{
base.Render(htmlwriter);
string html = htmlwriter.InnerWriter.ToString();
if ((ConfigurationManager.AppSettings.Get("RemoveWhitespace") + string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase))
{
// regex for removing html comment
html = Regex.Replace(html, @"((<!-- )((?!<!-- ).)*( -->))(\r\n)*", String.Empty);
// regex for removing line break & carriage return
html = html.Replace(";\r\n", ";");
}
writer.Write(html.Trim());
}
}