读书人

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

发布时间: 2012-01-13 22:43:30 作者: rapoo

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

读书人网 >C#

热点推荐