<TR>
<TD> 性 别: </TD>
<TD> 男 </TD>
上面的是某个html页面的一部分,我想获得性别的值:男
======================================================
String[] rS2 = new String[1];
string s2 = buffer;
string regexStr2 = " <TR> <TD> 性 别: </TD> <TD> (? <sex> [^ </TD> ]+) ";
string p2 = @regexStr2;
Regex reg2 = new Regex(p2);
Match m2 = reg2.Match(s2);
rS2[0] = m2.Groups[ "sex "].Value;
Response.Write(rS2[0]);
这样没有得到,我不太懂正则,请告知,谢谢
------解决方案--------------------------------------------------------
string re2 = " <span class=\ "wz5\ "> <br> (.*) </span> [ \f\n\r\t\v](.+) <br> [ \f\n\r\t\v](.+) <img src=\ "(.+)\ "> ";
Match match2 = Regex.Match(content, re2,RegexOptions.Singleline);
con2 = match2.Result( "$1 ");
Response.Write( "联系人: " + con2 + " <br/> ");
看看这个对你有用吗
------解决方案--------------------------------------------------------
string regexStr2 = @ "[\s\S]* <TR> [^ <]* <TD> 性 别: </TD> [^ <]* <TD> (? <sex> [^ <]+) </TD> [\s\S]* ";
------解决方案--------------------------------------------------------
不好意思,刚才有事,你这样试下
Match m2 = reg2.Match(s2, RegexOptions.IgnoreCase);
如果还不行,断点跟踪一下,贴下s2的内容