正则同时获取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;
}

posted on 2014-09-03 09:55  八度空间  阅读(2446)  评论(0)    收藏  举报

导航