日期:2014-05-18 浏览次数:21223 次
string s = @"<td><a href=""/lottery/draw/view/50"">双色球</a></td> <td>2012026期</td> <td>2012-03-06</td> <td> <div class=""ballbg""> <span class=""ball_1"">03</span> <span class=""ball_1"">07</span> <span class=""ball_1"">09</span> <span class=""ball_1"">15</span> <span class=""ball_1"">24</span> <span class=""ball_1"">25</span> <span class=""ball_2"">16</span> </div> </td>"; MatchCollection matches = Regex.Matches(s, @"(?is)(?<=双色球.*?)<span class=""ball_\d"">(\d+)</span>(?=.*?</div>)"); foreach (Match match in matches) Response.Write(match.Groups[1].Value + "<br/>");
------解决方案--------------------
string s = @"<td><a href=""/lottery/draw/view/50"">双色球</a></td> <td>2012026期</td> <td>2012-03-06</td> <td> <div class=""ballbg""> <span class=""ball_1"">03</span> <span class=""ball_1"">07</span> <span class=""ball_1"">09</span> <span class=""ball_1"">15</span> <span class=""ball_1"">24</span> <span class=""ball_1"">25</span> <span class=""ball_2"">16</span> </div> </td>"; MatchCollection matches = Regex.Matches(s, @"(?is)(?<=双色球</a></td>\s+<td>\d+期</td>.*?)<span class=""ball_\d"">(\d