コード例 #1
0
        /// <summary>
        /// 获取正则表达式
        /// </summary>
        /// <param name="pattern">正则表达式</param>
        /// <returns>正则表达式</returns>
        internal static string GetPattern(RegexPattern pattern)
        {
            string regexPattern = string.Empty;

            switch (pattern)
            {
            case RegexPattern.Mobile:
                regexPattern = RegexService.GetMobileRegex();
                break;

            case RegexPattern.Mail139Alias:
                regexPattern = RegexService.GetMail139AliasRegex();
                break;

            case RegexPattern.Mobile139Alias:
                regexPattern = RegexService.GetMobile139AliasRegex();
                break;

            case RegexPattern.MailPassword:
                regexPattern = RegexService.GetMailPasswordRegex();
                break;

            case RegexPattern.MailAddress:
                regexPattern = RegexService.GetMailAddressRegex();
                break;

            case RegexPattern.ChinaPhone:
                regexPattern = RegexService.GetChinaPhoneRegex();
                break;

            case RegexPattern.ChinaIDCard:
                regexPattern = RegexService.GetChinaIDCardRegex();
                break;

            case RegexPattern.ZipCode:
                regexPattern = RegexService.GetZipCodeRegex();
                break;

            case RegexPattern.IpAddress:
                regexPattern = RegexService.GetIpAddressRegex();
                break;

            case RegexPattern.Url:
                regexPattern = RegexService.GetUrlRegex();
                break;

            case RegexPattern.FileName:
                regexPattern = RegexService.GetFileNameRegex();
                break;

            case RegexPattern.Path:
                regexPattern = RegexService.GetPathRegex();
                break;

            case RegexPattern.NumberComma:
                regexPattern = RegexService.GetNumberCommaRegex();
                break;

            case RegexPattern.Number:
                regexPattern = RegexService.GetNumberRegex();
                break;

            case RegexPattern.Chinese:
                regexPattern = RegexService.GetChineseRegex();
                break;

            case RegexPattern.Letter:
                regexPattern = RegexService.GetLetterRegex();
                break;

            case RegexPattern.LetterNumberUnderline:
                regexPattern = RegexService.GetLetterNumberUnderlineRegex();
                break;

            case RegexPattern.yyyyMM:
                regexPattern = RegexService.GetYYYYMMRegex();
                break;

            case RegexPattern.SBCCheck:
                regexPattern = RegexService.GetSBCRegex();
                break;

            case RegexPattern.SpNumber:
                regexPattern = RegexService.GetSpNumberRegex();
                break;

            case RegexPattern.VerifyCode:
                regexPattern = RegexService.GetVerifyCodeRegex();
                break;
            }

            return(regexPattern);
        }