.NET去掉一段字符串中的HTML标记和脚本方法

using System.Text.RegularExpressions;

 

public static string NoHTML(string Htmlstring)
{

        //删除脚本
        Htmlstring = Regex.Replace(Htmlstring, @"]*?>.*?", "", RegexOptions.IgnoreCase);
        //删除HTML
        Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
        Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);

        Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);

        Htmlstring = Regex.Replace(Htmlstring, @"
                    

你可能感兴趣的:(.NET去掉一段字符串中的HTML标记和脚本方法)