去除字符中的脚本、样式、html标签

publicstaticstring DelHtml(thisstring Htmlstring)
    {

       
//删除脚本  
        Htmlstring = Regex.Replace(Htmlstring, @"<script(\s[^>]*?)?>[\s\S]*?</script>", "", RegexOptions.IgnoreCase);
       
//删除样式 
        Htmlstring = Regex.Replace(Htmlstring, @"<style>[\s\S]*?</style>", "", RegexOptions.IgnoreCase);
       
//删除html标签
        Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
       
return Htmlstring;

    }

posted @ 2012-08-10 15:56  宁静.致远  阅读(189)  评论(0编辑  收藏  举报