正则表达式获取td内容
<tdclass="cell-overflow-hidden"><divclass="content-wrapper"><divclass="widget-row-tit...
<td class="cell-overflow-hidden">
<div class="content-wrapper">
<div class="widget-row-title">
<div class="apply-common-tooltip" title="XPRY5">
<div class="select-marker"></div>
<div class="content-wrapper">XRPUSD, 1</div>
</div></div></div>
</td>
<td class="cell-overflow-hidden">
<div class="content-wrapper">
<div class="widget-row-title">
<div class="description-inner apply-common-tooltip" title="TEST_XPY">TEST_XPY
</div>
</div>
</div>
</td>
<td class="date">11:39</td>
这里面获取 11:39和TEST_XPY
哪位高手帮帮忙 万分感谢 展开
<div class="content-wrapper">
<div class="widget-row-title">
<div class="apply-common-tooltip" title="XPRY5">
<div class="select-marker"></div>
<div class="content-wrapper">XRPUSD, 1</div>
</div></div></div>
</td>
<td class="cell-overflow-hidden">
<div class="content-wrapper">
<div class="widget-row-title">
<div class="description-inner apply-common-tooltip" title="TEST_XPY">TEST_XPY
</div>
</div>
</div>
</td>
<td class="date">11:39</td>
这里面获取 11:39和TEST_XPY
哪位高手帮帮忙 万分感谢 展开
1个回答
展开全部
item是th里的内容,value是td里的。。。
var s = "内容........";
var regex = new System.Text.RegularExpressions.Regex(@"<th>(?<item>.*?)</th>[\s\S]+?<td>(?<value>.*?)</td>");
var ms = regex.Matches(s);
foreach (System.Text.RegularExpressions.Match m in ms)
{
Console.WriteLine(m.Groups["item"].Value);
Console.WriteLine(m.Groups["value"].Value);
}
var s = "内容........";
var regex = new System.Text.RegularExpressions.Regex(@"<th>(?<item>.*?)</th>[\s\S]+?<td>(?<value>.*?)</td>");
var ms = regex.Matches(s);
foreach (System.Text.RegularExpressions.Match m in ms)
{
Console.WriteLine(m.Groups["item"].Value);
Console.WriteLine(m.Groups["value"].Value);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询