正则表达式匹配 href 和text内容

string pattern = @"<a[^>]*href=(""(?<href>[^""]*)""|'(?<href>[^']*)'|(?<href>[^s>]*))[^>]*>(?<text>[sS]*?)</a>";

MatchCollection mcs = Regex.Matches(contenhtml, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);

href =mcs[0].Groups["href"].Value;

text=mcs[0].Groups["text"].Value;

原文地址:https://www.cnblogs.com/Xujg/p/3637962.html