zoukankan      html  css  js  c++  java
  • 字符串处理相关

      /// <summary>
            /// 去除HTML标签
            /// </summary>
            /// <param name="Htmlstring"></param>
            /// <returns></returns>
            public static string NoHTML(string Htmlstring)
            {
                //删除脚本
                Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", 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, @"<!--.*", "", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
                Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
                Htmlstring.Replace("<", "");
                Htmlstring.Replace(">", "");
                Htmlstring.Replace("\r\n", "");
                Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
                return Htmlstring;
            }
    
    字符串.Equals("forms", StringComparison.OrdinalIgnoreCase)//比较字符串是否相等,并忽略大小写
  • 相关阅读:
    C# WPF之Material Design自定义颜色
    C# WPF从RIOT API获取数据(RIOT代表作品《英雄联盟》)
    C# WPF聊天界面(3/3)
    C# WPF简况(2/3)
    C# WPF联系人列表(1/3)
    使用SignalR从服务端主动推送警报日志到各种终端(桌面、移动、网页)
    为什么Node.JS会受到青睐?
    2017级面向对象程序设计——团队作业1
    2017级面向对象程序设计 作业三
    如果抽不出时间写博客怎么办
  • 原文地址:https://www.cnblogs.com/zhangchen/p/2498912.html
Copyright © 2011-2022 走看看