zoukankan      html  css  js  c++  java
  • 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("不是汉字");

           }

  • 相关阅读:
    linux常用的基础知识
    【AW346】走廊泼水节
    【AW355】异象石
    【POJ3417】闇の連鎖
    【APIO2010】巡逻
    【SDOI2011】消防
    【BJWC2010】次小生成树
    【POJ3613】Cow Relays
    【POJ1734】Sightseeing trip
    【POJ1094】Sorting it all out
  • 原文地址:https://www.cnblogs.com/sui84/p/7018349.html
Copyright © 2011-2022 走看看