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;

            }

  • 相关阅读:
    安装adobe,路径My Pictures或卷无效。请重新输入。
    PrintDocument打印、预览、打印机设置和打印属性的方法(较完整) .
    C# 生成CODE128条码
    SQL2005 安装时 “性能监视器计数器要求(错误)” 解决方案
    Siebel escript学习笔记
    siebel 界面搭建
    Siebel Tools 开发笔记
    Siebel Tools配置
    Oracle:environment variable "PATH" does not exceed the recommended length
    IOS开发入门实例
  • 原文地址:https://www.cnblogs.com/ken-admin/p/6405762.html
Copyright © 2011-2022 走看看