如何截取电子邮件@前面的字符串[email protected]截取字符串得到  testasp

解决方案 »

  1.   

     string x="[email protected]";
            x=x.Substring(0,x.IndexOf("@"));
      

  2.   

    string email="[email protected]";
    string name=email.Slipt('@')[0];
      

  3.   


    //正则
                string str = "[email protected]";
                Regex reg = new Regex(@".*?(?=\@)");
                Match m = reg.Match(str);
                Response.Write(m.Value);
    //不过这种直接截取字符串就可以了
                Response.Write(str.Substring(0, str.IndexOf('@')));
      

  4.   

    string email="[email protected]";
    string name=email.Slipt('@')[0];
      

  5.   

    string x = "[email protected]";
    x = x.Substring(0, x.IndexOf("@"));
      

  6.   

    string x="[email protected]";
    x=x.Substring(0,x.IndexOf("@"));