一篇含有图片文字的文章 只获取他的文字部分作为简介  不获取图片该怎么实现

解决方案 »

  1.   

    你是说在asp.net中使用c#来获取,而这文章是一个html?
      

  2.   


    <p><font color="#ff0000"><strong>第107届中国进出口商品交易会</strong></font></p>
    <p>日期:第一期:2010年4月15日-19日 9:30-18:00<br />
    地点:中国进出口商品交易会展馆(琶洲)(中国广州海珠区阅江中路380号)<br />
    展馆:小型车辆与配件<br />
    展位号:4.1F 14-15</p>
    <p>&nbsp;</p>
    <p><img height="241" alt="" width="450" src="/UpLoadFile/img/201007270607403750.jpg" /></p>
    例如在这段文字里面  只获取文字内容
      

  3.   

    string strAbout = news;
            strAbout = Regex.Replace(strAbout, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
            strAbout = strAbout.Replace("<", "").Replace(">", "").Replace("&nbsp;", "");
            strAbout = strAbout.Replace("\r\n", "");
            return strAbout;大概这个意思在改改吧
      

  4.   

    最简单的方法就是你去百度下 搜下过滤html的代码  全部取过来 过滤一下就是你要的中文 gb2312了
      

  5.   


    string str = Content;
    str = Regex.Replace(str , @"<[^<]*)>", "", RegexOptions.IgnoreCase);
    str = str.Replace("&nbsp;", "");
    response.write(str);
      

  6.   


    void Main()
    {
    string ss = @"<p><font color='#ff0000'><strong>第107届中国进出口商品交易会</strong></font></p>
    <p>日期:第一期:2010年4月15日-19日 9:30-18:00<br />
    地点:中国进出口商品交易会展馆(琶洲)(中国广州海珠区阅江中路380号)<br />
    展馆:小型车辆与配件<br />
    展位号:4.1F 14-15</p>
    <p>&nbsp;</p>
    <p><img height='241' alt='' width='450' src='/UpLoadFile/img/201007270607403750.jpg' /></p>";
    Regex r = new Regex(@"[\u4e00-\u9fa5].*");
     foreach(Match  s in r.Matches(ss))
        {
        Console.WriteLine(Regex.Replace(s.Value,@"<.*>",""));
        }
    }
    //结果:
    第107届中国进出口商品交易会日期:第一期:2010年4月15日-19日 9:30-18:00地点:中国进出口商品交易会展馆(琶洲)(中国广州海珠区阅江中路380号)展馆:小型车辆与配件展位号:4.1F 14-15
      

  7.   

    Regex.Replace(str,@"<[^> ]+>",""); 过滤所有html