把<a href="ftp://ftp.sohu.com">ftp://ftp.sohu.com</a>
替换成ftp://ftp.sohu.com.同时<a href="http://www.sohu.com">http://www.sohu.com</a> 
能保持原样.谢谢!

解决方案 »

  1.   

    <a[^>]*>(?<ftpname>ftp:[^<]*)<[^>]*>
      
    //////////////////////////////////////////////
    MSN:[email protected]请给我一个与您交流的机会!
      

  2.   

    string sourceString = @"<a href=""ftp://ftp.sohu.com"">ftp://ftp.sohu.com</a><a href=""http://www.sohu.com"">http://www.sohu.com</a> ";
    string pattern = @"<a[^>]*>(?<ftpname>ftp:[^<]*)<[^>]*>";
    System.Text.RegularExpressions.Match result = Regex.Match(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase); WL(result.Groups[1].Value);
      
    //////////////////////////////////////////////
    MSN:[email protected]请给我一个与您交流的机会!
      

  3.   

    string reg = @">(?<s>ftp://ftp[^<]*)<";
    string str = "<a href=\"ftp://ftp.sohu.com\">ftp://ftp.sohu.com</a>";
    Response.Write( Regex.Match( str , reg , RegexOptions.IgnoreCase ).Groups["s"] );
      

  4.   

    ftp://ftp.sohu.com是根据href后的确定,还是根据<a...>和</a>这间的内容确定,同时是ftp://开头的替换,还是遵循其它规律,试下这个,如果不符合要求,具体说明一下string yourStr = .................;
    string result = Regex.Replace(yourStr, @"<a[^>]*>(ftp://[^<]*)</a>", "$1", RegexOptions.IgnoreCase);