比如说:<img style="width: 488px; height: 228px" height="215" src="http://static13.photo.sina.com.cn/bmiddle/4c0122eeg651d4364223c"
width="460" align="right" />
只要碰到“src = http://static13.photo.sina.com.cn”等于这个开头的话, 就吧整个<img ~~~~~/>全部删除 请问正则表达式怎么写。
width="460" align="right" />
只要碰到“src = http://static13.photo.sina.com.cn”等于这个开头的话, 就吧整个<img ~~~~~/>全部删除 请问正则表达式怎么写。
伪代码
if (img.src="XXXX"){
img.parent.removechild(img.index);
}JS, C#都可以做到.
其实就是抓取新浪的博客内容,里面的图片显示不出来,所以现在要去除它。有什么办法吗?
Regex.Replace(input,"(?i)<img[\\s\\S]*?src=\"http://static13.photo.sina.com.cn[^>]+>","");注意看你的 src="http 是单引号还是双引号还是没有 对应的改一改正则就可以了
也是可以的。
wackyboy你好, 刚才我试过你给我的了, 可是匹配不出来。 是双引号
string str = "<td><img style=\"width: 488px; height: 228px\" height=\"215\" src=\"http://static13.photo.sina.com.cn/bmiddle/4c0122eeg651d4364223c\" width=\"460\" align=\"right\" /></td><td><img style=\"width: 488px; height: 228px\" height=\"215\" src=\"http://static12.photo.sina.com.cn/bmiddle/4c0122eeg651d4364223c\" width=\"460\" align=\"right\" /></td><td><img style=\"width: 488px; height: 228px\" height=\"215\" src=\"http://static11.photo.sina.com.cn/bmiddle/4c0122eeg651d4364223c\" width=\"460\" align=\"right\" /></td> ";
string output = Regex.Replace(str,"(?i)<img[\\s\\S]*?src=\"http://static\\d+\\.photo\\.sina\\.com\\.cn[^>]+>",""); Console.WriteLine(output); // <td></td><td></td><td></td>