日期:2014-05-20  浏览次数:20987 次

正则表达式如何删除部分 <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);