日期:2014-05-18  浏览次数:20441 次

求一个正则表达式~~
<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);