for (int i = 0; i < 10; i++)
{
MatchCollection mc = Regex.Matches(html, @"<li class=['""]top-"+i.ToString()+@"['""]>(?<text>[\s\S]*?)</li>",RegexOptions.IgnoreCase);
string chulihtml = "";
foreach (Match m in mc)
{
chulihtml = m.Groups["text"].Value;
break;
}
{
MatchCollection mc = Regex.Matches(html, @"<li class=['""]top-"+i.ToString()+@"['""]>(?<text>[\s\S]*?)</li>",RegexOptions.IgnoreCase);
string chulihtml = "";
foreach (Match m in mc)
{
chulihtml = m.Groups["text"].Value;
break;
}
}
注意 @号
本文介绍了一段使用C#编程语言结合正则表达式从HTML中提取特定格式内容的代码示例。该示例展示了如何通过循环遍历与匹配的方式,精确获取带有特定类名的`<li>`标签内的文本内容。
2157

被折叠的 条评论
为什么被折叠?



