.net如何过滤图片 比如说我读取一段新闻,但里面有图片,我怎么才能将图片过滤掉? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 但里面有图片,新闻中图片一般都是以图片地址的形式存在的,正则匹配掉<img>。 字符串过滤img标签不就行了? 我才刚开始学,那么例如去掉<img src="images/index_02.jpg" width="736" height="84">就是相当于去掉了图片,但如何写代码过滤掉这个呢? System.Net.WebRequest wr = System.Net.WebRequest.Create(@"http://topic.csdn.net/u/20100706/14/a1d1c9cd-652f-413c-a27e-5ff1008149ac.html?4174"); System.Net.WebResponse wrs = wr.GetResponse(); System.IO.Stream sr = wrs.GetResponseStream(); System.IO.StreamReader srs = new System.IO.StreamReader(sr); string strValue = srs.ReadToEnd(); System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"<img.*src=(.*?)[^>]*?>"); System.Text.RegularExpressions.MatchCollection mc = r.Matches(strValue); foreach (System.Text.RegularExpressions.Match m in mc) { MessageBox.Show(m.Value); break; } 各位大侠们觉得 在递归遍历中 要用到对比字符串 那种方式快呢 行状态与版本问题 如何才能提高多表查询的性能 代码的逐语句跟踪为什么不能实现? 请问一下用C#开发WEB的有没有类似于datetimepicker的控件 是用progressbar时遇到问题 求助各位大神:C#打印文件换行问题 C#中如何实现类VC中的Toolbar 能不能这样访问property? [c# 初学-窗体] 设计一个可收缩的侧边导航栏 因为它在 17 偏移位置处包含一个对象字段,该字段已由一个非对象字段不正确地对齐或重叠。是什么意思?? 求助:如何使一段程序运行的时候,将程序锁定等待程序的运行?
<img src="images/index_02.jpg" width="736" height="84">
就是相当于去掉了图片,但如何写代码过滤掉这个呢?
System.Net.WebResponse wrs = wr.GetResponse(); System.IO.Stream sr = wrs.GetResponseStream();
System.IO.StreamReader srs = new System.IO.StreamReader(sr);
string strValue = srs.ReadToEnd(); System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"<img.*src=(.*?)[^>]*?>");
System.Text.RegularExpressions.MatchCollection mc = r.Matches(strValue);
foreach (System.Text.RegularExpressions.Match m in mc)
{
MessageBox.Show(m.Value);
break;
}