Regex reg = new Regex(@"(?is)<a\s+(?:(?<key>[^\s=]+)=(?<value>[^\s>]+)\s*)+>(?<text>(?:(?!</?a\b).)*)</a>");
MatchCollection mc = reg.Matches(html);
List<CategoryInfo> ctg = null;
if (mc.Count > 0)
{
ctg = new List<CategoryInfo>();
foreach (Match m in mc)
{
string v = m.Groups["value"].Value;
string t = m.Groups["text"].Value;
}
}
正则匹配获得匹配值
最新推荐文章于 2022-05-26 14:01:10 发布