用户找回密码有两种方式,一是通过密保问题,一是通过邮箱。
这里要说的是邮箱方式——
如果用户的邮箱已经通过了验证,则显示如下:
你的邮箱[email protected]已经通过验证,可以通过邮箱找回密码。
如果用户的邮箱尚未验证,则显示如下:
你的邮箱zh******@163.com尚未验证,不能通过邮箱找回密码。说白了,也就是邮箱的半隐藏处理
要求前缀显示前两个字符,其它的全由星号*替换,后缀全显示
举例:
[email protected] —— 7m*@sohu.com
[email protected] —— 54******@qq.com
[email protected] —— li**********@yahoo.com.cn请大侠们帮一把,谢谢!

解决方案 »

  1.   

    string after=name.Substring(0,2)+ new string('*', name.Length - 2);
      

  2.   

    string[] parts = name.Split("@");
                string name = parts[0];
                string domain = parts[1];
      

  3.   

    try...            string[] data = new string[] { "[email protected]", "[email protected]", "[email protected]" };
                Regex reg = new Regex(@"(?<=^[^@]{2}[^@]*)[^@]");
                foreach (string s in data)
                {
                    richTextBox2.Text += reg.Replace(s, "*") + "\n";
                }
      

  4.   

    int b = name.IndexOf("@", 0);
                string a = name.Substring(0, 2) + new string('*', b - 2 + 1) + name.Substring(b, name.Length - b);