<![if !vml]>
<span style='mso-ignore:vglayout;position:
absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'>
<img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032">
</span>
<![endif]>
<![if !vml]>
<img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032">
<![endif]>用正则试处理后(替换)变成
[img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]

解决方案 »

  1.   

    就是提取<![if !vml]><![endif]>中的img标记
      

  2.   

    形式1:
    <![if !vml]> 
    <span style='mso-ignore:vglayout;position: 
    absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'> 
    <img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 
    </span> 
    <![endif]> 
    形式2:
    <![if !vml]> 
    <img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 
    <![endif]> 把2种字符串用正则试都变成
    [img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]
      

  3.   

    <!\[if !vml\]>(.)*<img\s[^>]+>(.)*<!\[endif\]>
      

  4.   


    <![if !vml]> 
    <span style='mso-ignore:vglayout;position: 
    absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'> 
    <img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 
    </span> 
    <![endif]> 
    <![if !vml]> 
    <img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 
    <![endif]> <!--变化成--><![if !vml]> 
    <span style='mso-ignore:vglayout;position: 
    absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'> 
    [img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]
    </span> 
    <![endif]> <![if !vml]> 
    [img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]
    <![endif]> 
      

  5.   

    <img([^>])*>.*?</img([^>])*>
      

  6.   


    是替换成
    [img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/][img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]
      

  7.   


    string message = "<img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\">";
    Regex reg = new Regex("<img width=(\"?[0-9]*\"?) height=(\"?[0-9]*\"?) src=\"(.*?)\".*/?>");
    message = reg.Replace(message, "[img width=$1 height=$2 src=\"$3\" /]");
    Console.WriteLine(message);
      

  8.   

    message 替换成你要替换的全部字符串string message = "<![if !vml]><span style='mso-ignore:vglayout;position:absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\"></span><![endif]>";
    Regex reg = new Regex("<img width=(\"?[0-9]*\"?) height=(\"?[0-9]*\"?) src=\"(.*?)\".*/?>");
    message = reg.Replace(message, "[img width=$1 height=$2 src=\"$3\" /]");
    Console.WriteLine(message);
      

  9.   


    <![if !vml]> 
    <span style='mso-ignore:vglayout;position: 
    absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'> 
    <img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 
    </span> 
    <![endif]> 
    <![if !vml]> 
    <img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 
    <![endif]> <!--变化成-->
    [img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/][img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]
      

  10.   

    测试数据 <p class="MsoNormal" style="mso-outline-level:1">
    <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">二、在首页左上角选择<b>“电子商户</b></span><b><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt">-</span></b><b><span style="font-size:14.0pt;mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
    &quot;Times New Roman&quot;;mso-hansi-font-family:&quot;Times New Roman&quot;">商户证书下载”</span></b><span style="font-size:14.0pt;mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
    &quot;Times New Roman&quot;;mso-hansi-font-family:&quot;Times New Roman&quot;">;</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
    <p class="MsoNormal" align="center" style="text-align:center">
    <span lang="EN-US"><![if !vml]>
    <img border="0" width="451" height="333" src="民生银行电子商户(B2C___)证书下载步骤10.files/image004.jpg" v:shapes="_x0000_s1036"><![endif]><!--[if gte mso 9]><xml>

     <o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1026"
      DrawAspect="Content" ObjectID="_1277012795">
     </o:OLEObject>
    </xml><![endif]--></span><b><span lang="EN-US" style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt"><o:p></o:p></span></b></p>
    <p class="MsoNormal" style="mso-outline-level:1">
    <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">三、在打开的证书下载窗口输入<b>参考号、授权码</b>,下载商户证书;</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
    <p class="MsoNormal" align="center" style="text-align:center">
    <span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><![if !vml]>
    <img border="0" width="432" height="320" src="民生银行电子商户(B2C___)证书下载步骤10.files/image006.jpg" v:shapes="_x0000_s1035"><![endif]><o:p></o:p></span></p>
    <p class="MsoNormal" style="mso-outline-level:1">
    <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">四、证书下载成功后,输入<b>商户号</b>即可登录商户后台,查看网上支付订单信息;</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
    <p class="MsoNormal" align="center" style="text-align:center">
    <span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><![if !vml]>
    <img border="0" width="432" height="314" src="民生银行电子商户(B2C___)证书下载步骤10.files/image008.jpg" v:shapes="_x0000_s1034"><![endif]><o:p></o:p></span></p>
    <p class="MsoNormal" style="mso-outline-level:1">
    <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">五、该证书从浏览器导出后,可作为网上支付服务器加密私钥,具体导出证书操作如下图:</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
      

  11.   


    string message = "<![if !vml]><span style='mso-ignore:vglayout;position:absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\"></span><![endif]>";
    Regex reg = new Regex("<img border=\"0\" width=(\"?[0-9]*\"?) height=(\"?[0-9]*\"?) src=\"(.*?)\".*/?>");
    message = reg.Replace(message, "[img width=$1 height=$2 src=\"$3\" /]");
    Console.WriteLine(message);
      

  12.   


    //string text = "<![if !vml]><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\"><![endif]>"; 
    string text = "<![if !vml]><span style='mso-ignore:vglayout;position:absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\"></span><![endif]>"; 
    string s=System.Text.RegularExpressions.Regex.Replace(text,@"(<!\[if !vml\]>(<[^>]*?>)?)(<)(img[^>].*?)(>)((<[^>]*?>)?<!\[endif\]>)","[$4]",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    s=s.Replace("v:shapes=\"_x0000_s1032\"","");
    Response.Write(s);
      

  13.   

    如果v:shapes="_x0000_s1032"的位置固定的话(放在img元素的后面)也可以用一个正则替换://string text = "<![if !vml]><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\"><![endif]>"; 
    string text = "<![if !vml]><span style='mso-ignore:vglayout;position:absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif\" v:shapes=\"_x0000_s1032\"></span><![endif]>"; 
    string s=System.Text.RegularExpressions.Regex.Replace(text,@"(<!\[if !vml\]>(<[^>]*?>)?)(<)(img[^>].*?)(v:shapes=""(.*)"">)((<[^>]*?>)?<!\[endif\]>)","[$4]",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    Response.Write(s);
      

  14.   

    像元素位置不固定的这种情况(如<img中的border,weight,height,src等元素位置不定)正则替换可能就比较复杂了,这方面我也不太清楚,可能只有 root_,过客 等高手才能来解答,我也想知道^_^
      

  15.   

    <img\\s*[^>]*>
    我用这个都可以把Html中的Img 找出来
    然后 用 Src=[\\s]*[\"|'|\\s][^\"|'|\\s]+[\"|'|\\s]
    得到地址 
    不知道满足你的要求不
      

  16.   

    我测试是可以的啊。
    string message = "<img border=\"0\" width=\"432\" height=\"314\" src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image008.jpg\" v:shapes=\"_x0000_s1034\">";
    Regex reg = new Regex("<img border=\"0\" width=(\"?[0-9]*\"?) height=(\"?[0-9]*\"?) src=\"(.*?)\".*/?>");
    message = reg.Replace(message, "[img width=$1 height=$2 src=\"$3\" /]");
    Console.WriteLine(message);
      

  17.   

    999大哥的怎么用简单的可以测试通过,但是用我的测试字符就一个都不会替换    <p class="MsoNormal" style="mso-outline-level:1">
        <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">二、在首页左上角选择<b>“电子商户</b></span><b><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt">-</span></b><b><span style="font-size:14.0pt;mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
    &quot;Times New Roman&quot;;mso-hansi-font-family:&quot;Times New Roman&quot;">商户证书下载”</span></b><span style="font-size:14.0pt;mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
    &quot;Times New Roman&quot;;mso-hansi-font-family:&quot;Times New Roman&quot;">;</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
        <p class="MsoNormal" align="center" style="text-align:center">
        <span lang="EN-US"><![if !vml]>
        <img border="0" width="451" height="333" src="民生银行电子商户(B2C___)证书下载步骤10.files/image004.jpg" v:shapes="_x0000_s1036"><![endif]><!--[if gte mso 9]><xml>
        
     <o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1026"
      DrawAspect="Content" ObjectID="_1277012795">
     </o:OLEObject>
    </xml><![endif]--></span><b><span lang="EN-US" style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt"><o:p></o:p></span></b></p>
        <p class="MsoNormal" style="mso-outline-level:1">
        <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">三、在打开的证书下载窗口输入<b>参考号、授权码</b>,下载商户证书;</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
        <p class="MsoNormal" align="center" style="text-align:center">
        <span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><![if !vml]>
        <img border="0" width="432" height="320" src="民生银行电子商户(B2C___)证书下载步骤10.files/image006.jpg" v:shapes="_x0000_s1035"><![endif]><o:p></o:p></span></p>
        <p class="MsoNormal" style="mso-outline-level:1">
        <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">四、证书下载成功后,输入<b>商户号</b>即可登录商户后台,查看网上支付订单信息;</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
        <p class="MsoNormal" align="center" style="text-align:center">
        <span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><![if !vml]>
        <img border="0" width="432" height="314" src="民生银行电子商户(B2C___)证书下载步骤10.files/image008.jpg" v:shapes="_x0000_s1034"><![endif]><o:p></o:p></span></p>
        <p class="MsoNormal" style="mso-outline-level:1">
        <span style="font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:&quot;Times New Roman&quot;;
    mso-hansi-font-family:&quot;Times New Roman&quot;">五、该证书从浏览器导出后,可作为网上支付服务器加密私钥,具体导出证书操作如下图:</span><span lang="EN-US" style="font-size:14.0pt;mso-bidi-font-size:12.0pt"><o:p></o:p></span></p>
      

  18.   

    string text = ...;
    string s = Regex.Replace(text, @"\<!\[if\s+!vml\]>[\s\S]*?\<img.*?width=\""(?<width>\d+).+?height=\""(?<height>\d+).+?src=\""(?<src>[^\""]+)\"".*?\<!\[endif\]\>", @"[img width=${width} height=${height} src=\""${src}\""/]");
      

  19.   

    lz应注意那些转义字符。最好把<p class="MsoNormal" style="mso-outline-level:1">...这段要替换的字符写成代码贴上来。
    如:
    string text = "<p...<p>";
      

  20.   

    里面有换行符吧,多加几个\s试下:string s=System.Text.RegularExpressions.Regex.Replace(text,@"(<!\[if !vml\]>(<[^>]*?>)?)[\s]{0,}(<)(img[^>].*?)(>)[\s]{0,}((<[^>]*?>)?<!\[endif\]>)","[$4]",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
      

  21.   

    好像是标准的xml,用XmlDocument算了。
    用正则不难,就是情况太麻烦。
      

  22.   


    <p class=MsoNormal align=center style='text-align:center'><span lang=EN-US><!--[if gte vml 1]><v:shape
     id="_x0000_s1036" type="#_x0000_t75" style='width:338.25pt;height:249.75pt'>
     <v:imagedata src="民生银行电子商户(B2C___)证书下载步骤10.files/image003.png" o:title=""/>
    </v:shape><![endif]--><![if !vml]><img border=0 width=451 height=333
    src="民生银行电子商户(B2C___)证书下载步骤10.files/image004.jpg" v:shapes="_x0000_s1036"><![endif]><!--[if gte mso 9]><xml>
     <o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1026"
      DrawAspect="Content" ObjectID="_1277012795">
     </o:OLEObject>
    </xml><![endif]--></span><b><span lang=EN-US style='font-size:14.0pt;
    mso-bidi-font-size:12.0pt'><o:p></o:p></span></b></p><p class=MsoNormal style='mso-outline-level:1'><span style='font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
    mso-hansi-font-family:"Times New Roman"'>三、在打开的证书下载窗口输入<b>参考号、授权码</b>,下载商户证书;</span><span
    lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></p><p class=MsoNormal align=center style='text-align:center'><span lang=EN-US
    style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><!--[if gte vml 1]><v:shape
     id="_x0000_s1035" type="#_x0000_t75" style='width:324pt;height:240pt'>
     <v:imagedata src="民生银行电子商户(B2C___)证书下载步骤10.files/image005.png" o:title=""/>
    </v:shape><![endif]--><![if !vml]><img border=0 width=432 height=320
    src="民生银行电子商户(B2C___)证书下载步骤10.files/image006.jpg" v:shapes="_x0000_s1035"><![endif]><o:p></o:p></span></p><p class=MsoNormal style='mso-outline-level:1'><span style='font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
    mso-hansi-font-family:"Times New Roman"'>四、证书下载成功后,输入<b>商户号</b>即可登录商户后台,查看网上支付订单信息;</span><span
    lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></p><p class=MsoNormal align=center style='text-align:center'><span lang=EN-US
    style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><!--[if gte vml 1]><v:shape
     id="_x0000_s1034" type="#_x0000_t75" style='width:324pt;height:235.5pt'>
     <v:imagedata src="民生银行电子商户(B2C___)证书下载步骤10.files/image007.png" o:title=""/>
    </v:shape><![endif]--><![if !vml]><img border=0 width=432 height=314
    src="民生银行电子商户(B2C___)证书下载步骤10.files/image008.jpg" v:shapes="_x0000_s1034"><![endif]><o:p></o:p></span></p><p class=MsoNormal style='mso-outline-level:1'><span style='font-size:14.0pt;
    mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
    mso-hansi-font-family:"Times New Roman"'>五、该证书从浏览器导出后,可作为网上支付服务器加密私钥,具体导出证书操作如下图:</span><span
    lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></p><p class=MsoNormal align=center style='text-align:center'><!--[if gte vml 1]><v:oval
     id="_x0000_s1026" style='position:absolute;margin-left:99pt;margin-top:54.75pt;
     width:63pt;height:23.25pt;z-index:1' filled="f" strokecolor="red"
     strokeweight="1.5pt"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout;
    position:absolute;z-index:1;left:131px;top:72px;width:86px;height:33px'><img
    width=86 height=33 src="民生银行电子商户(B2C___)证书下载步骤10.files/image009.gif" v:shapes="_x0000_s1026"></span><![endif]><!--[if gte vml 1]><v:line
     id="_x0000_s1032" style='position:absolute;left:0;text-align:left;top:0;
     flip:x;z-index:7' from="90pt,78pt" to="108pt,81.75pt" strokecolor="red">
     <v:stroke endarrow="block"/>
    </v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
    absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'><img width=28
    height=12 src="民生银行电子商户(B2C___)证书下载步骤10.files/image010.gif" v:shapes="_x0000_s1032"></span><![endif]><!--[if gte vml 1]><v:oval
     id="_x0000_s1031" style='position:absolute;margin-left:54pt;margin-top:78pt;
     width:45pt;height:23.25pt;z-index:6' filled="f" strokecolor="red"
     strokeweight="1.5pt"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout;
    position:absolute;z-index:6;left:71px;top:103px;width:62px;height:33px'><img
    width=62 height=33 src="民生银行电子商户(B2C___)证书下载步骤10.files/image011.gif" v:shapes="_x0000_s1031"></span><![endif]><!--[if gte vml 1]><v:line
     id="_x0000_s1028" style='position:absolute;left:0;text-align:left;top:0;
     z-index:3' from="81pt,101.25pt" to="99pt,156pt" strokecolor="red">
     <v:stroke endarrow="block"/>
    </v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
    absolute;z-index:3;left:107px;top:134px;width:31px;height:78px'><img width=31
    height=78 src="民生银行电子商户(B2C___)证书下载步骤10.files/image012.gif" v:shapes="_x0000_s1028"></span><![endif]><!--[if gte vml 1]><v:line
     id="_x0000_s1030" style='position:absolute;left:0;text-align:left;top:0;
     z-index:5' from="108pt,179.25pt" to="3in,210.75pt" strokecolor="red">
     <v:stroke endarrow="block"/>
    </v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
    absolute;z-index:5;left:143px;top:238px;width:148px;height:49px'><img
    width=148 height=49 src="民生银行电子商户(B2C___)证书下载步骤10.files/image013.gif" v:shapes="_x0000_s1030"></span><![endif]><!--[if gte vml 1]><v:oval
     id="_x0000_s1029" style='position:absolute;margin-left:3in;margin-top:195pt;
     width:1in;height:31.5pt;z-index:4' filled="f" strokecolor="red"
     strokeweight="1.5pt"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout;
    position:absolute;z-index:4;left:287px;top:259px;width:98px;height:44px'><img
    width=98 height=44 src="民生银行电子商户(B2C___)证书下载步骤10.files/image014.gif" v:shapes="_x0000_s1029"></span><![endif]><!--[if gte vml 1]><v:oval
     id="_x0000_s1027" style='position:absolute;margin-left:1in;margin-top:156pt;
     width:45pt;height:23.25pt;z-index:2' filled="f" strokecolor="red"
     strokeweight="1.5pt"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout;
    position:absolute;z-index:2;left:95px;top:207px;width:62px;height:33px'><img
    width=62 height=33 src="民生银行电子商户(B2C___)证书下载步骤10.files/image011.gif" v:shapes="_x0000_s1027"></span><![endif]><span
    lang=EN-US><!--[if gte vml 1]><v:shape
     id="_x0000_s1033" type="#_x0000_t75" style='width:414.75pt;height:266.25pt'>
     <v:imagedata src="民生银行电子商户(B2C___)证书下载步骤10.files/image015.png" o:title=""/>
    </v:shape><![endif]--><![if !vml]><img border=0 width=553 height=355
    src="民生银行电子商户(B2C___)证书下载步骤10.files/image016.jpg" v:shapes="_x0000_s1033"><![endif]><!--[if gte mso 9]><xml>
     <o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1029"
      DrawAspect="Content" ObjectID="_1277012796">
     </o:OLEObject>
    </xml><![endif]--></span><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:
    12.0pt'><o:p></o:p></span></p>"
      

  23.   

    LZ太有才了,这样的代码可以用么?
    string p = @"\<!\[if\s+!vml\]>[\s\S]*?\<img.*?width=\""?(?<width>\d+).+?height=\""?(?<height>\d+).+?src=\""(?<src>[^\""]+)\"".*?\<!\[endif\]\>";
    string text = "<p class=MsoNormal align=center style='text-align:center'><span lang=EN-US><!--[if gte vml 1]><v:shape id=\"_x0000_s1036\" type=\"#_x0000_t75\" style='width:338.25pt;height:249.75pt'> <v:imagedata src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image003.png\" o:title=\"\"/> </v:shape><![endif]--><![if !vml]><img border=0 width=451 height=333 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image004.jpg\" v:shapes=\"_x0000_s1036\"><![endif]><!--[if gte mso 9]><xml> <o:OLEObject Type=\"Embed\" ProgID=\"PBrush\" ShapeID=\"_x0000_i1026\" DrawAspect=\"Content\" ObjectID=\"_1277012795\"> </o:OLEObject> </xml><![endif]--></span><b><span lang=EN-US style='font-size:14.0pt; mso-bidi-font-size:12.0pt'><o:p></o:p></span></b></p> <p class=MsoNormal style='mso-outline-level:1'><span style='font-size:14.0pt; mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:\"Times New Roman\"; mso-hansi-font-family:\"Times New Roman\"'>三、在打开的证书下载窗口输入<b>参考号、授权码</b>,下载商户证书;</span><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></p> <p class=MsoNormal align=center style='text-align:center'><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><!--[if gte vml 1]><v:shape id=\"_x0000_s1035\" type=\"#_x0000_t75\" style='width:324pt;height:240pt'> <v:imagedata src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image005.png\" o:title=\"\"/> </v:shape><![endif]--><![if !vml]><img border=0 width=432 height=320 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image006.jpg\" v:shapes=\"_x0000_s1035\"><![endif]><o:p></o:p></span></p> <p class=MsoNormal style='mso-outline-level:1'><span style='font-size:14.0pt; mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:\"Times New Roman\"; mso-hansi-font-family:\"Times New Roman\"'>四、证书下载成功后,输入<b>商户号</b>即可登录商户后台,查看网上支付订单信息;</span><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></p> <p class=MsoNormal align=center style='text-align:center'><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><!--[if gte vml 1]><v:shape id=\"_x0000_s1034\" type=\"#_x0000_t75\" style='width:324pt;height:235.5pt'> <v:imagedata src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image007.png\" o:title=\"\"/> </v:shape><![endif]--><![if !vml]><img border=0 width=432 height=314 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image008.jpg\" v:shapes=\"_x0000_s1034\"><![endif]><o:p></o:p></span></p> <p class=MsoNormal style='mso-outline-level:1'><span style='font-size:14.0pt; mso-bidi-font-size:12.0pt;font-family:宋体;mso-ascii-font-family:\"Times New Roman\"; mso-hansi-font-family:\"Times New Roman\"'>五、该证书从浏览器导出后,可作为网上支付服务器加密私钥,具体导出证书操作如下图:</span><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></p> <p class=MsoNormal align=center style='text-align:center'><!--[if gte vml 1]><v:oval id=\"_x0000_s1026\" style='position:absolute;margin-left:99pt;margin-top:54.75pt; width:63pt;height:23.25pt;z-index:1' filled=\"f\" strokecolor=\"red\" strokeweight=\"1.5pt\"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout; position:absolute;z-index:1;left:131px;top:72px;width:86px;height:33px'><img width=86 height=33 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image009.gif\" v:shapes=\"_x0000_s1026\"></span><![endif]><!--[if gte vml 1]><v:line id=\"_x0000_s1032\" style='position:absolute;left:0;text-align:left;top:0; flip:x;z-index:7' from=\"90pt,78pt\" to=\"108pt,81.75pt\" strokecolor=\"red\"> <v:stroke endarrow=\"block\"/> </v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position: absolute;z-index:7;left:117px;top:103px;width:28px;height:12px'><img width=28 height=12 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image010.gif\" v:shapes=\"_x0000_s1032\"></span><![endif]><!--[if gte vml 1]><v:oval id=\"_x0000_s1031\" style='position:absolute;margin-left:54pt;margin-top:78pt; width:45pt;height:23.25pt;z-index:6' filled=\"f\" strokecolor=\"red\" strokeweight=\"1.5pt\"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout; position:absolute;z-index:6;left:71px;top:103px;width:62px;height:33px'><img width=62 height=33 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image011.gif\" v:shapes=\"_x0000_s1031\"></span><![endif]><!--[if gte vml 1]><v:line id=\"_x0000_s1028\" style='position:absolute;left:0;text-align:left;top:0; z-index:3' from=\"81pt,101.25pt\" to=\"99pt,156pt\" strokecolor=\"red\"> <v:stroke endarrow=\"block\"/> </v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position: absolute;z-index:3;left:107px;top:134px;width:31px;height:78px'><img width=31 height=78 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image012.gif\" v:shapes=\"_x0000_s1028\"></span><![endif]><!--[if gte vml 1]><v:line id=\"_x0000_s1030\" style='position:absolute;left:0;text-align:left;top:0; z-index:5' from=\"108pt,179.25pt\" to=\"3in,210.75pt\" strokecolor=\"red\"> <v:stroke endarrow=\"block\"/> </v:line><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position: absolute;z-index:5;left:143px;top:238px;width:148px;height:49px'><img width=148 height=49 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image013.gif\" v:shapes=\"_x0000_s1030\"></span><![endif]><!--[if gte vml 1]><v:oval id=\"_x0000_s1029\" style='position:absolute;margin-left:3in;margin-top:195pt; width:1in;height:31.5pt;z-index:4' filled=\"f\" strokecolor=\"red\" strokeweight=\"1.5pt\"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout; position:absolute;z-index:4;left:287px;top:259px;width:98px;height:44px'><img width=98 height=44 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image014.gif\" v:shapes=\"_x0000_s1029\"></span><![endif]><!--[if gte vml 1]><v:oval id=\"_x0000_s1027\" style='position:absolute;margin-left:1in;margin-top:156pt; width:45pt;height:23.25pt;z-index:2' filled=\"f\" strokecolor=\"red\" strokeweight=\"1.5pt\"/><![endif]--><![if !vml]><span style='mso-ignore:vglayout; position:absolute;z-index:2;left:95px;top:207px;width:62px;height:33px'><img width=62 height=33 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image011.gif\" v:shapes=\"_x0000_s1027\"></span><![endif]><span lang=EN-US><!--[if gte vml 1]><v:shape id=\"_x0000_s1033\" type=\"#_x0000_t75\" style='width:414.75pt;height:266.25pt'> <v:imagedata src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image015.png\" o:title=\"\"/> </v:shape><![endif]--><![if !vml]><img border=0 width=553 height=355 src=\"民生银行电子商户(B2C___)证书下载步骤10.files/image016.jpg\" v:shapes=\"_x0000_s1033\"><![endif]><!--[if gte mso 9]><xml> <o:OLEObject Type=\"Embed\" ProgID=\"PBrush\" ShapeID=\"_x0000_i1029\" DrawAspect=\"Content\" ObjectID=\"_1277012796\"> </o:OLEObject> </xml><![endif]--></span><span lang=EN-US style='font-size:14.0pt;mso-bidi-font-size: 12.0pt'><o:p></o:p></span></p>";string s = System.Text.RegularExpressions.Regex.Replace(text,p, @"[img width=${width} height=${height} src=""${src}"" /]");
      

  24.   

    看来实现不了那就换其它思路
    把<img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif" v:shapes="_x0000_s1032"> 替换成
    [img width=28 height=12 src="民生银行电子商户(B2C___)证书下载步骤2.files/image002.gif"/]
    注意img标签有换行的情况
      

  25.   


    string result = Regex.Replace(str, @"<!\[if\s*!vml\]>[\s\S]*?<(img[^>]*?src=""[^""]*"")[^>]*>[\s\S]*?<!\[endif\]>", "[$1/]", RegexOptions.IgnoreCase);