110,534
社区成员
发帖
与我相关
我的任务
分享
一口吃的<a class="vote_down" href="http://www.sina.com" target="_blank">监考老师</a>发现一学生在作弊,便气急败坏地指着那学生吼道:你…你…你…你…你竟敢作弊,站起来!语毕,有<a id="problem_action" href="http://www.163.com" target="_blank">5名学生站了起来</a>!
一口吃的<a class="vote_down" href="http://www.sina.com" target="_blank">监考老师</a>发现一学生在作弊,便气急败坏地指着那学生吼道:你…你…你…你…你竟敢作弊,站起来!语毕,有<a id="problem_action" href="http://www.baidu.com" target="_blank">5名学生站了起来</a>!
var replaceStr = "http://www.baidu.com";
var keywords = "学生";
string html = @"一口吃的<a class=""vote_down"" href=""http://www.sina.com"" target =""_blank"" > 监考老师</a>发现一学生在作弊,便气急败坏地指着那学生吼道:你…你…你…你…你竟敢作弊,站起来!语毕,有<a id=""problem_action"" href =""http://www.163.com"" target =""_blank"" > 5名学生站了起来</a>!";
var pattern = string.Format(@"(?is)(?<=<a[^>]*?href\s="")[^""]*?(?=""[^>]*?>[\s\S]*?{0}[\s\S]*?</a>)", keywords);
Console.WriteLine(Regex.Replace(html, pattern, replaceStr));