C# 用正则取文本中所有链接

C# 用正则取文本中所有链接

 

            string pattern = @"<a\s*href=(""|')(?<href>[\s\S.]*?)(""|').*?>\s*(?<name>[\s\S.]*?)</a>";
            MatchCollection mc = Regex.Matches(srcString, pattern);
            foreach (Match m in mc)
            {
                Console.WriteLine("{0}---{1}", m.Groups["href"].Value, m.Groups["name"].Value);
            }
posted @ 2012-05-10 17:27  韩天伟  阅读(889)  评论(0编辑  收藏  举报