<p><strong><a href="http://www.xxx.com">某某公司</a></strong></p>如何用正则代码
获取href连接[http://www.xxx.com]
获取a标签文本[某某公司] 语言.NET 快速解决立马结贴

解决方案 »

  1.   

                string input = @"<p><strong><a href=""http://www.xxx.com"">某某公司</a></strong></p>";
                Regex regex = new Regex(@"<a\s+href=""(?<href>[^""]+)"">(?<value>[^<]+)</a>");
                MatchCollection collection = regex.Matches(input);
                foreach (Match item in collection)
                {
                    Console.WriteLine("href={0}     value={1}", item.Groups["href"].Value, item.Groups["value"].Value);
                }
      

  2.   


                 string input = @"<p><strong><a href=""http://www.xxx.com"">某某公司</a></strong></p>";
                 var first = Regex.Matches(input, @"<a.*?href=[""']([^""']+)[^>]+>([^<]+)</a>").Cast<Match>().Select(t => new { href = t.Groups[1].Value, txt = t.Groups[2].Value }).ToArray();