
正文
正则同时获取a标签里的href,text 2项
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
Regex regex2 = new Regex(@"<a[^>]+href=\s*(?:'(?<href>[^']+)'|""(?<href>[^""]+)""|(?<href>[^>\s]+))\s*[^>]*>(?<text>.*?)</a>", RegexOptions.IgnoreCase);
for (Match match2 = regex2.Match(html); match2.Success; match2 = match2.NextMatch())
{
string aname = match2.Groups["text"].Value;
string url = match2.Groups["href"].Value;
}







