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

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

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

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

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

posted on 2014-04-01 11:46  许广  阅读(937)  评论(0编辑  收藏  举报