62,254
社区成员
发帖
与我相关
我的任务
分享@"(?i)<a[^>]*?href=""(?<url>[^""]*)(?=[^>]*?target=""_blank"")(?<text>.+?)</a>";这个有 target...
void Main()
{
string str = "<a href=\"hello.html\" target=\"_blank\">hello</a><a href=\"1\">1</a><a href=\"hello2.html\" target=\"_blank\">hello2</a>";
Regex reg = new Regex(@"(?is)<a[^>]*target=""_blank""[^>]*>([^<]+)</a>");
MatchCollection mc = reg.Matches(str);
foreach (Match m in mc)
{
Console.WriteLine(m.Groups[1].Value + "\n");
}
/*
hello
hello2
*/
}
