Asp.Net正则获取链接地址

     string html = “html代码”;
        Regex reg = new Regex(@"(?is)<a[^>]*?href=(['""]?)(?<url>[^'""\s>]+)\1[^>]*>(?<text>(?:(?!</?a\b).)*)</a>");
        MatchCollection mc = reg.Matches(html);foreach (Match m in mc)
        {
            string url = m.Groups["url"].Value;
            string text = m.Groups["text"].Value;
        }

 

posted @ 2017-06-22 13:35  WebApi  阅读(1390)  评论(0编辑  收藏  举报
CopyRight © 博客园 WebAPI