比如说:<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 ~~~~~/>全部删除 请问正则表达式怎么写。

解决方案 »

  1.   

    这个用对象模型好做一些.
    伪代码
    if (img.src="XXXX"){
      img.parent.removechild(img.index);
    }JS, C#都可以做到.
      

  2.   

    因为我只能在cs文件中操作,不能使用js。 还有就是取得的内容是随机性的。
    其实就是抓取新浪的博客内容,里面的图片显示不出来,所以现在要去除它。有什么办法吗?
      

  3.   


    Regex.Replace(input,"(?i)<img[\\s\\S]*?src=\"http://static13.photo.sina.com.cn[^>]+>","");注意看你的 src="http 是单引号还是双引号还是没有 对应的改一改正则就可以了
      

  4.   

    其实不一定src=http://static13.photo.sina.com.cn  等于http://static11.photo.sina.com.cn 或者 http://static10.photo.sina.com.cn
    也是可以的。
    wackyboy你好, 刚才我试过你给我的了, 可是匹配不出来。 是双引号
      

  5.   


                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>