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);
            }

相关文章: