功能用途
主要实现了提取html代码中的a标签和url地址。
示例代码
Regex regex = new Regex("href\s*=\s*(?:"(?<1>[^"]*)"|(?<1>\S+))", RegexOptions.IgnoreCase); Regex regex1 = new Regex(@"<a.*hrefs*=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(); }