求正则表达式一枚
[解决办法]
另外,根据版主的表达式是可以得出结果的。
static void Main(string[] args)
{
string htmls = "<a href="http://www.csdn.net">CSDN</a><a href='http://www.baidu.com'>百度知道CSDN</a><a href='http://blog.csdn.net'>我的CSDN</a><a href="javascript:Login()">登陆CSDN</a><a href="http://Info.csdn.net">有关CSDN的信息</a><a href="http://www.google.hk">谷歌</a>";
Regex regTable = new Regex(@"(?i)<a\b[^>]*?href=(['""]?)(?<url>http://[^'""]+)\1[^>]*>(?<text>[^<>]*csdn[^<>]*)</a>");
var matches = regTable.Matches(htmls);
foreach (Match m in matches)
{
Console.WriteLine(m.Groups["text"].ToString());
Console.WriteLine(m.Groups["url"].ToString());
}
Console.Read();
}
CSDN
http://www.csdn.net
百度知道CSDN
http://www.baidu.com
我的CSDN
http://blog.csdn.net
有关CSDN的信息
http://Info.csdn.net