欲实现:过滤下文字符串中 第一个width='680' 的table
求C#正则表达式
字符串内容:<table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='center' valign='top' bgcolor='#ffffff' class='ps-body'>  
              来源:XXXX 作者:XXXX<br> 
              把人物处理成石像难度是非常大的,跟鼠绘一样,需要根据石雕手法把人物画出来。这里介绍一种最为简单的方法,不过精度不是很好,直接在人物素材上面处理,只需简单去色,增加细节和纹理,再润色即可。<br> 
              最终效果</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> 
      <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><a href='UploadFile1458/20121024/jc121024_1a.jpg' target='_blank'><img src='http://www.xxxx.com/2012/10/24/20121024095820_133.jpg' width='700' height='472' hspace='6' vspace='6' border='0'></a><br> 
              &lt;点小图查看大图&gt; </td> 
          </tr> 
        </tbody> 
      </table> 
      <br> 
      <table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='left' valign='top' bgcolor='#ffffff' class='ps-body'>1、打开背景素材,然后新建一个组。</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><a href='UploadFile1458/20121024/jc121024_2a.jpg' target='_blank'><img src='http://www.xxxx.com/2012/10/24/20121024095820_508.jpg' width='700' height='472' hspace='6' vspace='6' border='0'></a><br> 
              &lt;图1 点小图查看大图&gt; </td> 
          </tr> 
        </tbody> 
      </table> <table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='left' valign='top' bgcolor='#ffffff' class='ps-body'>2、打开人物素材,用钢笔把人物头部抠出来,拖到新建的组里面,适当调整好大小及位置,效果如图3。</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095820_962.jpg' width='560' height='617' hspace='6' vspace='6' border='0'><br> 
              &lt;图2&gt; </td> 
          </tr> 
        </tbody> 
      </table>  
      <br> 
      <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095821_214.jpg' width='527' height='399' hspace='6' vspace='6' border='0'><br> 
              &lt;图3&gt; </td> 
          </tr> 
        </tbody> 
      </table>  
      <br> 
      <table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='left' valign='top' bgcolor='#ffffff' class='ps-body'>3、把头像复制一层,按Ctrl  
              + Shift + U 去色,按Ctrl + M 调暗一点,原图层隐藏,效果如下图。</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095821_401.jpg' width='519' height='314' hspace='6' vspace='6' border='0'><br> 
              &lt;图4&gt; </td> 
          </tr> 
        </tbody> 
      </table>  
      <br> 
      <table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='left' valign='top' bgcolor='#ffffff' class='ps-body'>4、锁定图层透明像素,用涂抹工具把头发部分稍微涂抹一下去掉发丝细节。</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095821_532.jpg' width='516' height='300' hspace='6' vspace='6' border='0'><br> 
              &lt;图5&gt; </td> 
          </tr> 
        </tbody> 
      </table> <table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='left' valign='top' bgcolor='#ffffff' class='ps-body'>5、选择加深工具把暗部区域适当加深,再用减淡工具把高光部分涂亮一点,如下图。</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095821_750.jpg' width='512' height='285' hspace='6' vspace='6' border='0'><br> 
              &lt;图6&gt; </td> 
          </tr> 
        </tbody> 
      </table>  
      <br> 
      <table width='680' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td width='680' align='left' valign='top' bgcolor='#ffffff' class='ps-body'>6、新建一个图层,按Ctrl  
              + Alt + G 创建剪贴蒙版,用套索工具把下巴部分选取出来,羽化5个像素后在当前图层下面创建曲线调整图层,稍微调暗一点,参数设置如图8,效果如图9。</td> 
          </tr> 
        </tbody> 
      </table> 
      <br> <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095821_875.jpg' width='293' height='309' hspace='6' vspace='6' border='0'><br> 
              &lt;图7&gt; </td> 
          </tr> 
        </tbody> 
      </table>  
      <br> 
      <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095822_000.jpg' width='301' height='329' hspace='6' vspace='6' border='0'><br> 
              &lt;图8&gt; </td> 
          </tr> 
        </tbody> 
      </table>  
      <br> 
      <table border='0' align='center' cellpadding='4' cellspacing='1' bgcolor='#d3d3d3'> 
        <tbody> 
          <tr>  
            <td align='center' valign='center' bgcolor='#ffffff' class='ps-body'><img src='http://www.xxxx.com/2012/10/24/20121024095822_065.jpg' width='543' height='293' hspace='6' vspace='6' border='0'><br>  
              &lt;图9&gt; </td> 
          </tr> 
        </tbody> 
      </table> <br> 
     

解决方案 »

  1.   

    (?is)<table\swidth=(['"]?)680\1.*?>.*?</table>
      

  2.   

     
    var ary = Regex.Matches(str, @"<table\s*((?!width='680')[^>])+>((?!</table>)[\s\S])+</table>").Cast<Match>().Select(t => t.Value).ToArray();
      

  3.   

    真的有问题.....放到IDE试一下就知道了
      

  4.   

    双引号要转义的,这个最基本的,应该知道吧:
    Regex reg=new Regex(@"(?is)<table\swidth=(['""]?)680\1.*?>.*?</table>");