急.net正则表达式截取数据
<tr id="row_478301" class="ni" onmouseover="this.style.backgroundColor='#FFE6C5';" onMouseOut="this.style.backgroundColor='';" cansale="false" gamename="欧协杯" matchid="478301"><td onClick="hideRow('row_478301');" style="cursor: pointer;"><img src="/images/e.gif" align="absmiddle" />周三301</td><td style="color: #FFFFFF;background-color: #6F00DD ;"><a href='http://nba.bet007.com/league/index_cn.aspx?SclassID=21' target=_blank style='color:#FFF'>欧协杯</a></td><td style='color:#008;font-size:11px;'>11-21 23:00</td><td title="截止时间:2012-11-21 22:50"><font color=red>完场</font></td><td align="right"><span id="HomeOrder_142738"></span><a href="http://nba.310win.com/cn/Team/Summary.aspx?TeamID=982" target="_blank" id="HomeTeam_142738" onMouseOver="getMyHTML2_Lq('/temp/lq_982.htm','Vs_478301_982',null);" onMouseOut="hide('Vs_478301_982');" >圣彼得堡斯巴达 </a><div id="Vs_478301_982"> </div></td><td style="color: Red;font-weight:bold">89-71</td><td align="left"><a href="http://nba.310win.com/cn/Team/Summary.aspx?TeamID=970" target="_blank" class="dz14" id="GuestTeam_142738" onMouseOver="getMyHTML2_Lq('/temp/lq_970.htm','Vs_478301_970',null);" onMouseOut="hide('Vs_478301_970');" >乌尔姆</a><span id="GuestOrder_142738"></span><div id="Vs_478301_970"> </div></td><td class="op"></td><td class="op" style="color:#009;"></td><td class="op"></td><td><a target="_blank" href="/handicap/lanqiu/142738.html">亚</a><a target="_blank" href="/1x2/lanqiu/142738.html" style="margin:0px 2px 0px 2px">欧</a><a target="_blank" href="/analysis/basketball/142738.htm">析</a> <a style="display:" href="javascript:" onclick="ShowOddsWinow('/Handle/JcBasketSp.aspx?oddsType=3&spid=9825&typeID=111','WinOdds',event);">变</a><a href="/Info/BetPointList.aspx?sid=142738&bt=2" target="_blank"><img src="/images/t2.gif" alt="急net正则表达式截取数据,该怎么处理" style='cursor:pointer;display:'/></a></td><td id="cell_478301_1" title="主胜" ><span id="sp_478301_1" style="font-weight:bold;">1.08</span></td><td id="cell_478301_2" title="客胜" ><span id="sp_478301_2" style="font-weight:bold;">3.95</span></td><td id="cell_478301_all"><input type="checkbox" name="selall478301" id="selall478301" onClick="selectBatch3(478301,this.checked,'11月21日22:50');" style="display:none" /></td> </tr>
这是我要截取的数据源
Regex regex3 = new Regex("<td style="color: Red;font-weight:bold"/>(?<value>.*?)</td>", RegexOptions.IgnoreCase);
Match macht3 = regex3.Match(StrHtml);
Arr[7] = macht3.Groups[1].Value.Trim();这是我写的正则表达式
<td style="color: Red;font-weight:bold">89-71</td>这是我要截取的数据,请各位高手看看怎么截取不到数据谢谢!!!!!!!
[最优解释]
你的正则多了一个 /
Regex regex3 = new Regex("<td style="color: Red;font-weight:bold"/>(?<value>.*?)</td>", RegexOptions.IgnoreCase);
去掉红色部分
[其他解释]
string str = File.ReadAllText("D:\\1.txt", Encoding.Default).Replace("\\r\\n", "\r\n");
var ary = Regex.Match(str, @"<td\s*style=([""']?)[^""']+\1\s*>[0-9\-]+</td>").Value;
string str = File.ReadAllText("D:\\1.txt", Encoding.Default);
var ary = Regex.Match(str, @"<td\s*style=([""']?)[^""']+\1\s*>[0-9\-]+</td>").Value;