• asp.net过滤HTML方法


    可以扩展很多,也可以用此方法做采集信息,

    fck("过滤的字符串", @"<font color=""#ff0000"">.*?</font>", @"<font color=""#ff0000"">", @"</font>")

     public string fck(string htmls, string pattern, string patternstart, string patternend)
            {
                Regex regex = new Regex(@pattern, RegexOptions.IgnoreCase);
                MatchCollection mc = regex.Matches(htmls);
                string htmlreplace = string.Empty;
                foreach (Match m in mc)
                {
                    if (m.Success)
                    {
                        htmlreplace = m.Value.Replace(patternstart, "");
                        htmlreplace = htmlreplace.Replace(patternend, "");
                        htmls = htmls.Replace(m.Value, htmlreplace);
                    }
                }
                return htmls;
            }

  • 相关阅读:
    观察者模式
    模版方法
    event
    设计模式之观察者模式
    BOM
    javascript基础语法&4
    Document Object Model
    javascript基础语法&3
    javaScript基础语法&1
    sublimeText3安装
  • 原文地址:https://www.cnblogs.com/stulife/p/1710390.html
Copyright © 2020-2023  润新知