Exemple #1
0
        /// <summary>
        /// 扩张方法 转换字符串默认为 ""
        /// </summary>
        /// <returns></returns>
        public static string ToMaskString(this object s)
        {
            string str = s.ToEString();

            if (string.IsNullOrEmpty(str))
            {
                return("");
            }
            else
            {
                if (RegularValidateHelper.IsMobilePhoneNumber(str) && str.Length == 11)
                {
                    return(str.Substring(0, 3) + "****" + str.Substring(7, 4));
                }
                else
                {
                    if (str.Length == 2)
                    {
                        return(str.Substring(0, 1) + GetMask(1));
                    }
                    if (str.Length > 2)
                    {
                        return(str.Substring(0, 1) + GetMask(str.Length - 2) + str.Substring(str.Length - 1, 1));
                    }
                }
                return(s.ToString());
            }
        }
Exemple #2
0
        /// <summary>
        /// 验证是否特殊用户【内部用户】
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public static bool SpecialUser(string username)
        {
            var ret    = false;
            var regStr = @"^(13[6-9]0000\d{4}|[a-z]+)$";

            if (RegularValidateHelper.IsMatch(username, regStr))
            {
                ret = true;
            }
            return(ret);
        }