在一篇文章内容里面
string content="内容";
怎么替换除了http://www.inwayedu这个链接以外的所有链接
就是除了http://www.inwayedu这个开头以外的链接
其他所有的链接都要被替换
 求代码,谢谢

解决方案 »

  1.   

    提取所有连接,然后用函数处理
    reg.Replace(source, new MatchEvaluator(CapText));private string CapText(Match m)
            {
                //这里判断是否是http://www.inwayedu
            }
      

  2.   

    content=Regex.Replace(content,"http://(?!www\\.inwayedu)\\S+","");
      

  3.   

    大哥,你的貌似可以
    但是怎么把非http://www.inwayedu
     的这个部分,所有的http://www
    替换成
    rel="nofollow" href="http://www
      

  4.   

    content=Regex.Replace(content,"http://(?!www\\.inwayedu)\\S+","rel=\"nofollow\" href=\"$0\"");
      

  5.   

    不行呢,条件对了链接有http://www.inwayedu的没替换
    可以是其他的都替换成href="rel=" 了
    乱了
      

  6.   

    前:
    <a href="http://www.inwayedu.com">xxxxxx</a>
    <a href="http://www.gokuai.com">xxxx</a>后:
    <a href="http://www.inwayedu.com">xxxxxx</a>
    <a href="rel=">xxxxxx</a>我的功能是,除了上面的哪个url外,其他全部的URL都加一个rel="nofollow"
    求代码
      

  7.   

    \bhttp\:\/\/www\.inwayedu\s*\b
    难道是这样?我是来抛砖的
      

  8.   

    content=Regex.Replace(content,"http://(?!www\\.inwayedu)[^\\s'"]+","rel=");