首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

正则表达式怎么删除部分 <img中的信息

2012-01-13 
正则表达式如何删除部分 img中的信息例如:imgsrc http://topic.csdn.net/ui/images/logo_csdn.gif bo

正则表达式如何删除部分 <img中的信息
例如:
<img   src= "http://topic.csdn.net/ui/images/logo_csdn.gif "   border= "0 "   onload= "if(this.width> screen.width*0.7)   {this.resized=true;......>
正则后变成
<img   src= "http://topic.csdn.net/ui/images/logo_csdn.gif "   border= "0 ">
就是把border=后面的部分全去掉,然后加上 "0 ">

[解决办法]
string newValue = Regex.Match(Htmlstring, " <img[^> ]*?border= ", RegexOptions.IgnoreCase).Value + "0> ";
Htmlstring = Regex.Replace(Htmlstring, " <img[^> ].*> ", newValue, RegexOptions.IgnoreCase);

热点排行