• c# 验证


    public class RegularExpressionsHelper
        {
            /// <summary>
            /// 对用户名进行格式进行检查的正则表达式
            /// </summary>
            /// <param name="userName">输入的用户名</param>
            /// <returns>验证结果</returns>
            public static bool UserNameRegex(string userName)
            {
                string nameRegex = @"^[0-9a-zA-Z_-]{6,16}$";
                return Regex.IsMatch(userName, nameRegex);
            }
    
            /// <summary>
            /// 验证手机号的正则表达式
            /// </summary>
            /// <param name="mobilePhoneNumber">输入的手机号</param>
            /// <returns>验证结果</returns>
            public static bool MobilePhoneNumberRegex(string mobilePhoneNumber)
            {
                string phoneNumberRegex = @"^1[3578]d{9}$";
                return Regex.IsMatch(mobilePhoneNumber, phoneNumberRegex);
            }
    
            /// <summary>
            /// 对邮箱进行验证的正则表达式
            /// </summary>
            /// <param name="emial">输入的邮箱</param>
            /// <returns>验证结果</returns>
            public static bool EmailRegex(string emial)
            {
                string emailRegex = @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$";
                return Regex.IsMatch(emial, emailRegex); ;
            }
    
            /// <summary>
            /// 判断输入发字符串是否为GUID
            /// </summary>
            /// <param name="guid">输入的字符串</param>
            /// <returns>验证结果</returns>
            public static bool GuidRegex(string guid)
            {
                string guidRegex = @"^[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-Z0-9]{12}$";
                return Regex.IsMatch(guid, guidRegex);
            }
    
            /// <summary>
            /// 判断输入的字符串时候为车牌号
            /// </summary>
            /// <param name="carNumber">输入的字符串</param>
            /// <returns>验证结果</returns>
            public static bool CarNumReges(string carNumber)
            {
                string carNumReges = @"^[u4E00-u9FA5][A-Za-z][dA-za-z]{5}$";
                return Regex.IsMatch(carNumber, carNumReges);
            }
        }
  • 相关阅读:
    web每隔几秒页面刷新
    lucene.Net (C#)
    hibernatesearch
    org.simpleframework.xml.core.Persister
    Hibernate 注解 annotation
    WebService大讲堂之Axis2(2):复合类型数据的传递
    myEclipse代码格式化
    WebService大讲堂之Axis2(1):用POJO实现0配置的WebService
    Hibernate Search基本配置和使用
    java.sql.preparedstatement的应用
  • 原文地址:https://www.cnblogs.com/liuqiyun/p/10910223.html
Copyright © 2020-2023  润新知