现在获取一段字符串,可能是:
[email protected]
xb@yah
bbbbb@yahoo.
dddd@yaho
[email protected]通过replace无法让后面的后辍统一起来!我想让它们都变成
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]请问有什么解决方法,请指教!

解决方案 »

  1.   

    if(!str.contains(".cn"))
    {
        //在后面加上.cn
    }
    这么做字符串数量多的情况下性能可能不佳
      

  2.   

    string str = "dddd@yaho ";
    int index = str.LastIndexOf('@'); string oldString = str.Substring(index, str.Length - index);
    str = str.Replace(oldString, "yahoo.cn");
      

  3.   

    str.split("@")(0)+ "@yahoo.cn"
    这样行不行啊
    不过看起来好笨的方法
      

  4.   

    谢谢大家的指点
    现在我获取的又出现新的问题获取的资料现在有可能是:
    [email protected] 
    xb@yah 
    [email protected]
    bbbbb@yahoo. 
    [email protected]
    dddd@yaho 
    [email protected]
    [email protected]如何把它们都替换完整?
    谢谢了.
      

  5.   

    string[] a = { "[email protected]", "xb@yah", "bbbbb@yahoo." };
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = a[i].Substring(0, a[i].IndexOf("@")) + "@yahoo.cn";
                Response.Write (a[i] + "<br/>");
            }
      

  6.   

    string str = "abc@yah";
    int index = str.LastIndexOf("@");
    string changestr = str.Substring(index+1);
    string newstr=str.Replace(changestr, "yahoo.cn");
    newstr就是转换后的结果[email protected]