<tr onmouseover=”this.style.background=”#d2eafa”” onmouseout=”this.style.background=”none”” gameid=”609752″ gamenum=”4004″ gamedate=”20160505″ >
<td>周四004</td>
<td class=”t” style=”background: #004488; color: #fff; border-bottom:1px #fff solid; height:29px;”>
<td>周四004</td>
<td class=”t” style=”background: #004488; color: #fff; border-bottom:1px #fff solid; height:29px;”>
<a href=”http://data.jc258.cn/cupmatch/index/73″ target=”_blank”>
瑞典杯</a>
</td>
<td>05-05 21:30</td>
<td><a href=”http://data.jc258.cn/battle/609752/0″ target=”_blank”> 马尔默
<span style=”color:#f00″>(-1)</span>
VS
赫根</a></td>
<td>2:0</td>
<td>2:2</td>
<td ><span class=”red”>平</span></td>
<td ><span class=”odds_c”>4.15</span></td>
<td ><span class=”red”>负</span></td>
<td ><span class=”odds_c”>2.52</span></td>
<td ><span class=”red”>4</span></td>
<td >5.00</td>
<td ><span class=”red”>2:2</span></td>
<td >16.00</td>
<td ><span class=”red”>胜平</span></td>
<td >15.00</td>
<td><a href=”/jingcai/matchresult/ftbdetail/80411″ target=”_blank”>详细</a></td>
</tr>
需要获取红色字体部分的数据,求一段正则表达式!谢过
解决方案
40
下班了,再写一个笨办法,能提取干净的文本;供lz参考,也希望高手们指点
string inputStr = "<td ><span class="odds_c">4.15</span></td><a href="http://data.jc258.cn/cupmatch/index/73" target="_blank"> 瑞典杯</a><td>周四004</td><td ><span class="odds_c">4.15</span></td><td><a href="http://data.jc258.cn/battle/609752/0" target="_blank"> 马尔默 <span style="color:#f00">(-1)</span> VS 赫根</a></td>"; string outPut = ""; inputStr = new Regex(@"<a.+?>").Replace(inputStr, string.Empty); inputStr = new Regex(@"</a>").Replace(inputStr, string.Empty); inputStr = new Regex(@"<span.*?>").Replace(inputStr, string.Empty); inputStr = new Regex(@"</span>").Replace(inputStr, string.Empty); Regex rx=new Regex(@"(?<=>).+?(?=<)"); foreach(Match m in rx.Matches(inputStr)) { outPut += m.Value + "--"; //本人的测试环境是web控制台,提取出的内容之间用--分开,方便阅读 } Response.Write(outPut);
输出:
4.15– 瑞典杯–周四004–4.15– 马尔默 (-1) VS 赫根–