62,046
社区成员
发帖
与我相关
我的任务
分享
string test = @"<a href=""http://中国.com"" title=""我爱中国"">虽然我在新加坡长大,但我是中国人 </a>
<div title=""中国的美"">伟大的中国 </div>";
string result = Regex.Replace(test, @"(?<=^|</a>|<(?!/?a)[^>]*>)[^<>]*?(?=<a[^>]*>|<(?!/?a)[^>]*>|$)", delegate(Match m) { return m.Value.Replace("中国", @"<a href=""www.china.net"">中国</a>"); }, RegexOptions.IgnoreCase);
richTextBox2.Text = result;