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

相关文章:

  • 2021-08-14
  • 2022-12-23
  • 2021-07-30
  • 2021-12-15
  • 2022-12-23
  • 2022-02-07
  • 2021-06-01
  • 2022-12-23
猜你喜欢
  • 2021-09-25
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案