110,530
社区成员
发帖
与我相关
我的任务
分享
string input = @"<a href=""http://www.csdn.net"" title=""CSDN"">CSDN论坛 </a>";
Regex re = new Regex(@"(?si)<a\s+.*?href=['""](?<href>[^'""]+)['""].*?>(?<content>.*?)</a>");
MatchCollection mc = re.Matches(input);
foreach (Match m in mc)
{
Console.WriteLine(string.Format("href: {0},content: {1}", m.Groups["href"].Value,m.Groups["content"].Value));
}
string str = " <ul> <li> <a href=''http://news.163.com/09/0202/22/51692E9F0001121M.html''>蒙古国寒冬致6万多头牲畜死亡 </a> <span>02月02日";
Regex r = new Regex( @"(?<=href=\'').+(?=\'')" );
MessageBox.Show( r.Match(str).Value );