zoukankan      html  css  js  c++  java
  • C#内容格式刷html 转成txt

    /// <summary>

            /// 内容格式刷

            /// </summary>

            /// <param name="strHtml">要格式的文本</param>

            /// <returns></returns>

            public static string HtmlToTxt(string strHtml)

            {

                string[] aryReg ={

                @"<script[^>]*?>.*?</script>",

                @"<(/s*)?!?((w+:)?w+)(w+(s*=?s*(([""'])(\[""'tbnr]|[^7])*?7|w+)|.{0})|s)*?(/s*)?>",

                @"([ ])[s]+",

                @"&(quot|#34);",

                @"&(amp|#38);",

                @"&(lt|#60);",

                @"&(gt|#62);", 

                @"&(nbsp|#160);", 

                @"&(iexcl|#161);",

                @"&(cent|#162);",

                @"&(pound|#163);",

                @"&(copy|#169);",

                @"&#(d+);",

                @"-->",

                @"<!--.* "

                };

                string newReg = aryReg[0];

                string strOutput = strHtml;

                for (int i = 0; i < aryReg.Length; i++)

                {

                    Regex regex = new Regex(aryReg[i], RegexOptions.IgnoreCase);

                    strOutput = regex.Replace(strOutput, string.Empty);

                }

                strOutput.Replace("<", "");

                strOutput.Replace(">", "");

                strOutput.Replace(" ", "");

                return strOutput;

            }

  • 相关阅读:
    MaxScale智能读写
    flask简单demo
    django简单demo
    git原生私服之git&gitweb
    gerrit 解决中文乱码相关配置(转载)
    gerrit集成gitweb:Error injecting constructor, java.io.IOException: Permission denied
    gerrit: Error in POST /accounts/self/preferences
    redmine 配置邮件发送为async后,不能发送邮件(转载)
    gerrit error: unpack failed: error Permission denied
    centos修改hostname以及时间同步
  • 原文地址:https://www.cnblogs.com/ken-admin/p/6405762.html
Copyright © 2011-2022 走看看