ValidateUtil.cs
上传用户:yinyuehua
上传日期:2022-08-10
资源大小:17k
文件大小:6k
源码类别:

matlab例程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.     public class ValidateUtil
  7.     {
  8.         /// <summary>
  9.         /// 年度
  10.         /// </summary>
  11.         /// <returns></returns>
  12.         public static ArrayList ALLYEARS()
  13.         {
  14.             ArrayList alyear = new ArrayList();
  15.             int i;
  16.             for (i = 1990; i <= 2020; i++)
  17.                 alyear.Add(i);
  18.             return alyear;
  19.         }
  20.         /// <summary>
  21.         /// Blank
  22.         /// </summary>
  23.         /// <param name="strInput"></param>
  24.         /// <returns></returns>
  25.         public static bool isBlank(string Input)
  26.         {
  27.             if (Input == null || Input.Trim() == "")
  28.             {
  29.                 return true;
  30.             }
  31.             else
  32.             {
  33.                 return false;
  34.             }
  35.         }
  36.         /// <summary>
  37.         /// Email
  38.         /// </summary>
  39.         /// <param name="txtemail"></param>
  40.         /// <returns></returns>
  41.         public static bool isEmail(string Email)
  42.         {
  43.             Regex r = new Regex("\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.CultureInvariant);
  44.             return r.IsMatch(Email);
  45.         }
  46.         /// <summary>
  47.         /// Phone
  48.         /// </summary>
  49.         /// <param name="txtphone"></param>
  50.         /// <returns></returns>
  51.         public static bool isPhone(string Phone)
  52.         {
  53.             Regex r = new Regex("((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}", RegexOptions.CultureInvariant);
  54.             return r.IsMatch(Phone);
  55.         }
  56.         /// <summary>
  57.         /// Fax
  58.         /// </summary>
  59.         /// <param name="txtphone"></param>
  60.         /// <returns></returns>
  61.         public static bool isFax(string Fax)
  62.         {
  63.             Regex r = new Regex("((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}", RegexOptions.CultureInvariant);
  64.             return r.IsMatch(Fax);
  65.         }
  66.         /// <summary>
  67.         /// Mobile
  68.         /// </summary>
  69.         /// <param name="txtmobile"></param>
  70.         /// <returns></returns>
  71.         public static bool isMobile(string Mobile)
  72.         {
  73.             Regex r = new Regex("((\(\d{3}\))|(\d{3}\-))?13\d{9}", RegexOptions.CultureInvariant);
  74.             return r.IsMatch(Mobile);
  75.         }
  76.         /// <summary>
  77.         /// URL
  78.         /// </summary>
  79.         /// <param name="txtURL"></param>
  80.         /// <returns></returns>
  81.         public static bool isURL(string URL)
  82.         {
  83.             Regex r = new Regex("http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]':+!]*([^<>""])*", RegexOptions.CultureInvariant);
  84.             return r.IsMatch(URL);
  85.         }
  86.         /// <summary>
  87.         /// IDCard
  88.         /// </summary>
  89.         /// <param name="IDCard"></param>
  90.         /// <returns></returns>
  91.         public static bool isIDCard(string IDCard)
  92.         {
  93.             Regex r = new Regex("\d{15}(\d{2}[A-Za-z0-9])?", RegexOptions.CultureInvariant);
  94.             return r.IsMatch(IDCard);
  95.         }
  96.         /// <summary>
  97.         /// Currency
  98.         /// </summary>
  99.         /// <param name="Currency"></param>
  100.         /// <returns></returns>
  101.         public static bool isCurrency(string Currency)
  102.         {
  103.             Regex r = new Regex("\d+(\.\d+)?", RegexOptions.CultureInvariant);
  104.             return r.IsMatch(Currency);
  105.         }
  106.         /// <summary>
  107.         /// Number
  108.         /// </summary>
  109.         /// <param name="Number"></param>
  110.         /// <returns></returns>
  111.         public static bool isNumber(string Number)
  112.         {
  113.             Regex r = new Regex("\d+", RegexOptions.CultureInvariant);
  114.             return r.IsMatch(Number);
  115.         }
  116.         /// <summary>
  117.         /// Zip
  118.         /// </summary>
  119.         /// <param name="Zip"></param>
  120.         /// <returns></returns>
  121.         public static bool isZip(string Zip)
  122.         {
  123.             Regex r = new Regex("[1-9]\d{5}", RegexOptions.CultureInvariant);
  124.             return r.IsMatch(Zip);
  125.         }
  126.         /// <summary>
  127.         /// QQ
  128.         /// </summary>
  129.         /// <param name="QQ"></param>
  130.         /// <returns></returns>
  131.         public static bool isQQ(string QQ)
  132.         {
  133.             Regex r = new Regex("[1-9]\d{4,8}", RegexOptions.CultureInvariant);
  134.             return r.IsMatch(QQ);
  135.         }
  136.         /// <summary>
  137.         /// Integer
  138.         /// </summary>
  139.         /// <param name="Integer"></param>
  140.         /// <returns></returns>
  141.         public static bool isInteger(string Integer)
  142.         {
  143.             Regex r = new Regex("[-\+]?\d+", RegexOptions.CultureInvariant);
  144.             return r.IsMatch(Integer);
  145.         }
  146.         /// <summary>
  147.         ///  Double
  148.         /// </summary>
  149.         /// <param name="Double"></param>
  150.         /// <returns></returns>
  151.         public static bool isDouble(string Double)
  152.         {
  153.             Regex r = new Regex("[-\+]?\d+(\.\d+)?", RegexOptions.CultureInvariant);
  154.             return r.IsMatch(Double);
  155.         }
  156.         /// <summary>
  157.         /// English
  158.         /// </summary>
  159.         /// <param name="English"></param>
  160.         /// <returns></returns>
  161.         public static bool isEnglish(string English)
  162.         {
  163.             Regex r = new Regex("[A-Za-z]+", RegexOptions.CultureInvariant);
  164.             return r.IsMatch(English);
  165.         }
  166.         /// <summary>
  167.         /// Chinese
  168.         /// </summary>
  169.         /// <param name="Chinese"></param>
  170.         /// <returns></returns>
  171.         public static bool isChinese(string Chinese)
  172.         {
  173.             Regex r = new Regex("[\u0391-\uFFE5]+", RegexOptions.CultureInvariant);
  174.             return r.IsMatch(Chinese);
  175.         }
  176.     }