当前位置: 代码迷 >> ASP.NET >> 怎么在后台过滤 script 标签
  详细解决方案

怎么在后台过滤 script 标签

热度:4967   发布时间:2013-02-25 00:00:00.0
如何在后台过滤 script 标签
RT
 求思路,最好是能有model~

------解决方案--------------------------------------------------------
C# code
Htmlstring = Regex.Replace(Htmlstring, @"(?is)<script\b[^>]*>(.*?)</script>", string.Empty, RegexOptions.IgnoreCase);
------解决方案--------------------------------------------------------
string js = @"asdf
<script>
alert
</script>
asdfads
<Script type=''>alert<script>asdfasdf
";
js= Regex.Replace(js,@"\<\s*script(\s|.)*?script\s*\>","",RegexOptions.IgnoreCase);
  相关解决方案