功能用途

主要实现了提取html代码中的a标签和url地址。

示例代码

     Regex regex = new Regex("href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase);
            Regex regex1 = new Regex(@"\<a.*href\s*=\s*(?:""(?<url>[^""]*)""|\'(?<url>[^\']*)\'|(?<url>[^\>^\s]+)).*\>(?<title>[^\<^\>]*)\<[^\</a\>]*/a\>", RegexOptions.IgnoreCase);

            for (Match m = regex1.Match(pageindex); m.Success; m = m.NextMatch())
            {
                string tempurl = m.Groups[1].Value.ToString();
                string title = m.Groups[2].Value.ToString();
}

版权声明:本文为shya原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/shya/p/2439446.html