想实现功能是 有个方法,功能为  [email protected]  返回 abc@***.*** 不知该方法该如何写,并且,放置在哪里才能所有页面都方便调用???

解决方案 »

  1.   

    用正则来替换 
    写一个静态方法,比如StringHelper.HiddenEmail(String email){}
      

  2.   


    用正则写一个替换邮箱名的方法放app_code中
      

  3.   

    能写一个么,刚接触不久,写了几种格式总说有错误。放于 App_code 目录下了,不用实现功能也行,我就看看格式
      

  4.   


     public static string test(string s)
            {
                string result;
                Regex r = new Regex(@"(?<=@).*(?=\.)|(?<=\.).*");
                string r1 = r.Match(s).Value;
                string r2 = r.Match(s).NextMatch().Value;            result =s.Replace(r1,new string('*',r1.Length)).Replace(r2,new string('*',r2.Length));
                return result;
            }
    //将此方法封装在一公共类中 可实现所有页面都能调用
    //调用时 公共类.test("[email protected]");
      

  5.   

    自定义类库,静态方法
    调的DLL
    如IP
    Regex.Replace("", @"((\d{1,3}\.){3,})(\d{1,3})", "$1"+"***");
      

  6.   

    public static string HiddenEmail(string email)
        {
            return email;
        }
    这种格式可以吧?
      

  7.   

    写一个webservice
    或者写一个静态方法