LK.WXAD.Commons/Patterns.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace LK.WXAD.Commons
{
    using System;
    using System.Text.RegularExpressions;

    public static class Patterns
    {

        /** 取随机数 */
        public static string BuildRandomStr(int length)
        {
            Random rand = new Random();

            int num = rand.Next();

            string str = num.ToString();

            if (str.Length > length)
            {
                str = str.Substring(0, length);
            }
            else if (str.Length < length)
            {
                int n = length - str.Length;
                while (n > 0)
                {
                    str.Insert(0, "0");
                    n--;
                }
            }

            return str;
        }
       

        public static bool IsChinese(string str)
        {
            Regex regex = new Regex("u4e00-u9fa5");
            return regex.IsMatch(str);
        }

        public static bool IsCode(string str)
        {
            Regex regex = new Regex("^[0-9]{15,18}$");
            return regex.IsMatch(str);
        }

        public static bool IsDateTime(string str)
        {
            Regex regex = new Regex("^[ ]*[012 ]?[0-9]?[0-9]{2}[ ]*[-]{1}[ ]*[01]?[0-9]{1}[ ]*[-]{1}[ ]*[0123]?[0-9]{1}[ ]*[012]?[0-9]{1}[ ]*[:]{1}[ ]*[012345]?[0-9]{1}[ ]*[:]{1}[ ]*[012345]?[0-9]{1}[ ]*$");
            return regex.IsMatch(str);
        }

        public static bool IsDoubleByteChar(string str)
        {
            Regex regex = new Regex("[^x00-xff]");
            return regex.IsMatch(str);
        }

        public static bool IsEMail(string str)
后面还有 70 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。