lxcnn(过客) 大哥进来
1. <td class=CSS_TD_LEFT2 width=45% valign=top> [帐号] patrickcao <br> [姓名] 曹东生 <br> [积分] 2分 <br> <a href=javascript:OpwCollection(0,2855, '曹东生 ');> <img src=../images/user/collect.GIF border=0 title= '加为好友 ' align=absmiddle width=16 height=16> [加为好友] </a> </a> </td>
抓出 "[姓名] "后的名字
2. <td class=CSS_TD_LEFT2 valign=top> 班级:外语90 </td>
抓出 "班级: "后的所在班级名称
这两个正则怎么写,谢谢了!!
------解决方案--------------------try
1、
string yourStr = ............;
string name = " ";
Match m = Regex.Match(yourStr, @ "\[姓名\](? <name> [^ <]*) ");
if (m.Success)
name = m.Groups[ "name "].Value.Trim();
2、
string yourStr = ............;
string className = " ";
Match m = Regex.Match(yourStr, @ "班级:(? <class> [^ <]*) ");
if (m.Success)
className = m.Groups[ "class "].Value.Trim();