• RegularExpression正则表达式


    1.必須為大寫字母,小寫字母,數字和符號的至少其中3種組合 The new password should contain any three of different syntax which is Upper Case Character, Lower Case Character, Numeral and Symbol.

    [RegularExpression(@"^((?=.*d)(?=.*[A-Z])(?=.*[-+?*$[]^.()|`!@#%&_=:;',/])|(?=.*d)(?=.*[a-z])(?=.*[A-Z])|(?=.*d)(?=.*[a-z])(?=.*[-+?*$[]^.()|`!@#%&_=:;',/])|(?=.*[a-z])(?=.*[A-Z])(?=.*[-+?*$[]^.()|`!@#%&_=:;',/])).+$", ErrorMessage = DisplayMsgs.InvalidPassword)] public string NewPassword { get; set; }

    2.必須為大寫字母,小寫字母,數字,長度須為6~8位 RegularExpression(@"[A-Za-z0-9]{6,8}", ErrorMessage = DisplayMsgs.InvalidEncryptKey)] [Required(ErrorMessage = "Encrypt Key" + DisplayMsgs.RequiredInput)] public String  EncryKey { get; set; }

    string regex = @"^[A-Za-z0-9]{6,8}$"; if (string.IsNullOrEmpty(request.EncryptionKey) || !Regex.IsMatch(request.EncryptionKey.Trim(), regex)) { response.Status = ResponseStatuses.InvalidEncryKey;           return response; }

    3.漢字

    string text = "是不是汉字,ABC,keleyi.com";

            for (int i = 0; i < text.Length; i++)

            {

                   if (Regex.IsMatch(text[i].ToString(), @"[u4e00-u9fbb]+{1}quot;))

                       Console.WriteLine("是汉字");

                   else

                       Console.WriteLine("不是汉字");

            }                 用ASCII码判断         string text = "是不是汉字,ABC,柯乐义";

           for (int i = 0; i < text.Length; i++)

           {

                if ((int)text[i] > 127)

                      Console.WriteLine("是汉字");

                else

                      Console.WriteLine("不是汉字");

           }

  • 相关阅读:
    NYOJ926(概率)
    无根树转有根树
    Codeforces Round #304 C(Div. 2)(模拟)
    hdu5878(枚举,打表)
    求一个矩阵的逆矩阵(用伴随矩阵求)
    求n阶方阵的值(递归)
    setw()函数
    快速幂计算(整数快速幂/矩阵快速幂)
    全文检索
    发送邮件
  • 原文地址:https://www.cnblogs.com/sui84/p/7018349.html
Copyright © 2020-2023  润新知