比如:<a href="http://www.baidu.com">http://www.baidu.com</a>替换后的格式如
<a href="http://www.baidu.com" target="_blank">http://www.baidu.com</a>最好能有完整代码。

解决方案 »

  1.   

    string a = "<a href='a'>a</a><a href='b'>b</a>";
    Regex reg = new Regex(@"(?i)<a ([^>]+?)>(.+?)</a>");
    a = reg.Replace(a, "<a $1 target=_blank>$2</a>");
      

  2.   

    try...string test = "<a href=\"http://www.baidu.com\">http://www.baidu.com </a> ";
    Regex reg = new Regex(@"(?i)(?<=<a\b(?:(?!target=)[^>])*)(?=>)");
    string result = reg.Replace(test, " target=\"_blank\"");
      

  3.   

    谢谢各位回复。lxcnn的答案正解。感谢了。