• 过滤HTML字符显示摘要


    public static string GetSummary(string html, int summaryLength)
        
    {
            
    string text = GetHtmlText(html);
            text 
    = DelHTML(text);
            text 
    = Strtitle(text);
            
    if (summaryLength >= text.Length)
                
    return text;
            
    return text.Substring(0, summaryLength)+"";
        }


        
    public static string GetHtmlText(string html)
        
    {
            
    return System.Text.RegularExpressions.Regex.Replace(html, @"<[^>]*>""");
        }

        
    public static string DelHTML(string Htmlstring)//将HTML去除
        {
            

            
    return Htmlstring.Trim();
        }

        
    public static string DelWords(string strtitle)
        
    {
            
    string strContent = strtitle;
            strtitle 
    = Regex.Replace(strContent, "(<H1.*?>|</H1>|</br>|<SPAN.*?>|</SPAN>|<FONT.*?>||<o:p></o:p>)""");
            strContent 
    = strtitle;
            strContent 
    = Regex.Replace(strContent, "(<IMG.*?>)""");
            strContent 
    = Regex.Replace(strContent, "(<P.*?>)""");
            strContent 
    = Regex.Replace(strContent, "(<P>)""");
            strContent 
    = Regex.Replace(strContent, "(&nbsp;)""");
            strContent 
    = Regex.Replace(strContent, "(&rdquo;)""");
            strContent 
    = Regex.Replace(strContent, "(</P>)""");
            strContent 
    = Regex.Replace(strContent, "(</BR>)""");
            strContent 
    = Regex.Replace(strContent, "(<BR>)""");
            strContent 
    = strContent.Replace("<?xml:namespace prefix = o ns = 'urn:schemas-microsoft-com:office:office'/>""");
            
    return strtitle;
        }
  • 相关阅读:
    KindEditor
    java大文件(百M以上)的上传下载分享
    java大文件(百M以上)的上传下载问题
    java大文件(百M以上)的上传下载方法
    java大文件(百M以上)的上传下载思路
    飞镖靶计分题[待]
    Hive高级(1):优化(1) 执行计划/ Fetch 抓取 /本地模式
    Hadoop基础:补充:Zookeeper的目录结构
    Hadoop基础:补充:hadoop的目录结构介绍
    java 基本语法(二十):mysql JDBC URL格式各个参数详解
  • 原文地址:https://www.cnblogs.com/cnaspnet/p/1216790.html
Copyright © 2020-2023  润新知