首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

正则表达式~

2011-12-27 
求一个正则表达式~~tablestyle border-collapse:collapse bordercolor #111111 cellspacing 0 c

求一个正则表达式~~
<table   style= "border-collapse:   collapse "   bordercolor= "#111111 "   cellspacing= "0 "   cellpadding= "0 "   width= "610 "   border= "1 "   align= "center ">
    <tr>
        <td>       </td>
    </tr>
</table>
</P>
<IMG   title= "123 "   src=\ "http://192.19.19.43/test.gif "   align=left>
</P>
<P> &nbsp;456 </P>

结果:123456

——————————————
忽略所有html标记     除 <IMG> 的title值




[解决办法]
try

string result = Regex.Replace(yourStr, @ " <img[^> ]*title=([ ' " "]?)(? <title> [^ ' " "]*)\1?[^> ]*> ", "${title} ", RegexOptions.IgnoreCase);
result = Regex.Replace(result, @ "( <[^> ]*> |\s|&nbsp;) ", " ");

[解决办法]
or

string yourStr = ..............;
string result = Regex.Replace(yourStr, @ "( <img[^> ]*title=([ ' " "]?)(? <title> [^ ' " "]*)\1?[^> ]*> | <[^> ]*> |\s|&nbsp;) ", "${title} ", RegexOptions.IgnoreCase);

热点排行