Apple开发_正则表达式相关

  • NSString+Regex.h

#import <Foundation/Foundation.h>

// 正则表达式相关
@interface NSString (Regex)

// 邮箱验证
- (BOOL)is_Email;

// 手机号码验证
- (BOOL)is_Phone_Num;

// 车牌号验证
- (BOOL)is_Car_No;

// 网址验证
- (BOOL)is_Url;

// 邮政编码
- (BOOL)is_Postal_Code;

// 纯汉字
- (BOOL)is_Chinese;

// 是否符合IP格式, xxx.xxx.xxx.xxx
- (BOOL)is_Valid_IP;

// 身份证验证 refer to http://blog.csdn.net/afyzgh/article/details/16965107
- (BOOL)is_IdCard_Num;

/**
 * @brief 是否符合最小长度、最长长度, 是否包含中文, 数字, 字母, 其他字符, 首字母是否可以为数字
 * @param minLenth 账号最小长度
 * @param maxLenth 账号最长长度
 * @param containChinese 是否包含中文
 * @param containDigtal 包含数字
 * @param containLetter 包含字母
 * @param containOtherCharacter 其他字符
 * @param first_cannot_be_digtal 首字母不能为数字
 * @return 正则验证成功返回YES, 否则返回NO
 */
- (BOOL)isValidWithMinLenth:(NSInteger)min_lenth
                   maxLenth:(NSInteger)max_lenth
             containChinese:(BOOL)contain_chinese
              containDigtal:(BOOL)contain_digtal
              containLetter:(BOOL)contain_letter
      containOtherCharacter:(NSString *)contain_other_character
        firstCannotBeDigtal:(BOOL)first_cannot_be_digtal;

// 去掉两端空格和换行符
- (NSString *)strip;

// 去掉html格式
- (NSString *)remove_Html_Format;

// 工商税号
- (BOOL)is_Tax_No;

@end
  • NSString+Regex.m

#import "NSString+Regex.h"

@implementation NSString (Regex)

// 邮箱验证
- (BOOL)is_Email {
    NSString *email_regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *email_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", email_regex];
    return [email_test evaluateWithObject:self];
}

// 手机号码验证
- (BOOL)is_Phone_Num {
    // 手机号以13, 14, 15, 17, 18, 19开头, 八个 \d 数字字符
    NSString *phone_regex = @"^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[0-9])[0-9]{8}$";
    NSPredicate *phone_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phone_regex];
    return [phone_test evaluateWithObject:self];
}

// 车牌号验证
- (BOOL)is_Car_No {
    NSString *car_regex = @"^[A-Za-z]{1}[A-Za-z_0-9]{5}$";
    NSPredicate *car_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", car_regex];
    return [car_test evaluateWithObject:self];
}

// 网址验证
- (BOOL)is_Url {
    NSString *regex = @"^((http)|(https))+:[^\\s]+\\.[^\\s]*$";
    
    NSPredicate *gc_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [gc_pre evaluateWithObject:self];
}

// 邮政编码
- (BOOL)is_Postal_Code {
    NSString *phone_regex = @"^[0-8]\\d{5}(?!\\d)$";
    NSPredicate *phone_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phone_regex];
    return [phone_test evaluateWithObject:self];
}

// 纯汉字
- (BOOL)is_Chinese {
    NSString *phone_regex = @"^[\u4e00-\u9fa5]+$";
    NSPredicate *phone_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phone_regex];
    return [phone_test evaluateWithObject:self];
}

- (BOOL)is_Valid_IP {
    NSString *regex = [NSString stringWithFormat:@"^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$"];
    NSPredicate *gc_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    BOOL gc_rc = [gc_pre evaluateWithObject:self];
   
    if (gc_rc) {
        NSArray *componds_a = [self componentsSeparatedByString:@","];
       
        BOOL gc_v = YES;
        for (NSString *gc_s in componds_a) {
            if (gc_s.integerValue > 255) {
                gc_v = NO;
                break;
            }
        }
       
        return gc_v;
    }
   
    return NO;
}

// 身份证验证 refer to http://blog.csdn.net/afyzgh/article/details/16965107
- (BOOL)is_IdCard_Num {
    NSString *gc_value = [self copy];
    gc_value = [gc_value stringByReplacingOccurrencesOfString:@"X" withString:@"x"];
    gc_value = [gc_value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    int length = 0;
    if (!gc_value) {
        return NO;
    }
    else {
        length = (int)gc_value.length;
        if (length != 15 && length != 18) {
            return NO;
        }
    }
    // 省份代码
    NSArray *areas_array = @[@"11", @"12", @"13", @"14", @"15", @"21", @"22", @"23", @"31", @"32", @"33", @"34", @"35", @"36", @"37", @"41", @"42", @"43", @"44", @"45", @"46", @"50", @"51", @"52", @"53", @"54", @"61", @"62", @"63", @"64", @"65", @"71", @"81", @"82", @"91"];
    NSString *value_start2 = [gc_value substringToIndex:2];
    BOOL area_flag = NO;
    for (NSString *area_code in areas_array) {
        if ([area_code isEqualToString:value_start2]) {
            area_flag = YES;
            break;
        }
    }
    if (!area_flag) {
        return NO;
    }
    NSRegularExpression *regularExpression;
    NSUInteger numberofMatch;
    int gc_year = 0;
    switch (length) {
        case 15:
            gc_year = [gc_value substringWithRange:NSMakeRange(6, 2)].intValue + 1900;
            if (gc_year % 4 == 0 || (gc_year % 100 == 0 && gc_year % 4 == 0)) {
                // 测试出生日期的合法性
                regularExpression = [[NSRegularExpression alloc] initWithPattern:@"^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$" options:NSRegularExpressionCaseInsensitive error:nil];
            }
            else {
                // 测试出生日期的合法性
                regularExpression = [[NSRegularExpression alloc] initWithPattern:@"^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$" options:NSRegularExpressionCaseInsensitive error:nil];
            }
            numberofMatch = [regularExpression numberOfMatchesInString:gc_value options:NSMatchingReportProgress range:NSMakeRange(0, gc_value.length)];
            if (numberofMatch > 0) {
                return YES;
            }
            else {
                return NO;
            }
        case 18:
            gc_year = [gc_value substringWithRange:NSMakeRange(6, 4)].intValue;
            if (gc_year % 4 == 0 || (gc_year % 100 == 0 && gc_year % 4 == 0)) {
                // 测试出生日期的合法性
                regularExpression = [[NSRegularExpression alloc] initWithPattern:@"^[1-9][0-9]{5}19|20[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$"options:NSRegularExpressionCaseInsensitive error:nil];
               
            }
            else {
                // 测试出生日期的合法性
                regularExpression = [[NSRegularExpression alloc] initWithPattern:@"^[1-9][0-9]{5}19|20[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$"
                                                                        
                                                                         options:NSRegularExpressionCaseInsensitive error:nil];
            }
            numberofMatch = [regularExpression numberOfMatchesInString:gc_value options:NSMatchingReportProgress range:NSMakeRange(0, gc_value.length)];
            if (numberofMatch > 0) {
                int gc_s = ([gc_value substringWithRange:NSMakeRange(0, 1)].intValue + [gc_value substringWithRange:NSMakeRange(10, 1)].intValue) * 7 + ([gc_value substringWithRange:NSMakeRange(1, 1)].intValue + [gc_value substringWithRange:NSMakeRange(11, 1)].intValue) * 9 + ([gc_value substringWithRange:NSMakeRange(2, 1)].intValue + [gc_value substringWithRange:NSMakeRange(12, 1)].intValue) * 10 + ([gc_value substringWithRange:NSMakeRange(3, 1)].intValue + [gc_value substringWithRange:NSMakeRange(13, 1)].intValue) * 5 + ([gc_value substringWithRange:NSMakeRange(4, 1)].intValue + [gc_value substringWithRange:NSMakeRange(14, 1)].intValue) * 8 + ([gc_value substringWithRange:NSMakeRange(5, 1)].intValue + [gc_value substringWithRange:NSMakeRange(15, 1)].intValue) * 4 + ([gc_value substringWithRange:NSMakeRange(6, 1)].intValue + [gc_value substringWithRange:NSMakeRange(16, 1)].intValue) * 2 + [gc_value substringWithRange:NSMakeRange(7, 1)].intValue * 1 + [gc_value substringWithRange:NSMakeRange(8, 1)].intValue * 6 + [gc_value substringWithRange:NSMakeRange(9, 1)].intValue * 3;
                int gc_y = gc_s % 11;
                NSString *gc_m = @"F";
                NSString *gc_jym = @"10X98765432";
                // 判断校验位
                gc_m = [gc_jym substringWithRange:NSMakeRange(gc_y, 1)];
                if ([gc_m isEqualToString:[[gc_value substringWithRange:NSMakeRange(17, 1)] uppercaseString]]) {
                    // 检测ID的校验位
                    return YES;
                }
                else {
                    return NO;
                }
            }
            else {
                return NO;
            }
           
        default:
            return NO;
    }
    return NO;
}

/**
 * @brief 是否符合最小长度、最长长度, 是否包含中文, 数字, 字母, 其他字符, 首字母是否可以为数字
 * @param minLenth 账号最小长度
 * @param maxLenth 账号最长长度
 * @param containChinese 是否包含中文
 * @param containDigtal 包含数字
 * @param containLetter 包含字母
 * @param containOtherCharacter 其他字符
 * @param first_cannot_be_digtal 首字母不能为数字
 * @return 正则验证成功返回YES, 否则返回NO
 */
- (BOOL)isValidWithMinLenth:(NSInteger)min_lenth
                   maxLenth:(NSInteger)max_lenth
             containChinese:(BOOL)contain_chinese
              containDigtal:(BOOL)contain_digtal
              containLetter:(BOOL)contain_letter
      containOtherCharacter:(NSString *)contain_other_character
        firstCannotBeDigtal:(BOOL)first_cannot_be_digtal {
    BOOL gc_rc = YES;
    if (first_cannot_be_digtal) {
        NSString *regex = @"^[0-9]+.*";
        NSPredicate *gc_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
        gc_rc = [gc_pre evaluateWithObject:self];
        if (gc_rc) {
            return NO;
        }
    }
   
    NSString *gc_hanzi = contain_chinese ? @"\u4e00-\u9fa5" : @"";
    NSString *digtal_regex = contain_digtal ? @"0-9" : @"";
    NSString *containOtherCharacterRegex = contain_other_character ? contain_other_character : @"";
    NSString *character_regex = [NSString stringWithFormat:@"[%@A-Za-z%@%@]", gc_hanzi, digtal_regex, containOtherCharacterRegex];
    NSString *regex = [NSString stringWithFormat:@"%@{%@,%@}", character_regex, @(min_lenth), @(max_lenth)];
    NSPredicate *gc_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [gc_pre evaluateWithObject:self];
}

// 去掉两端空格和换行符
- (NSString *)strip {
    return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}

// 去掉html格式
- (NSString *)remove_Html_Format {
    NSString *gc_str = [NSString stringWithFormat:@"%@", self];
   
    NSError *error;
    NSRegularExpression *gc_regex = [NSRegularExpression regularExpressionWithPattern:@"<[^>]*>" options:NSRegularExpressionCaseInsensitive error:&error];
    if (!error) {
        gc_str = [gc_regex stringByReplacingMatchesInString:gc_str options:0 range:NSMakeRange(0, gc_str.length) withTemplate:@"$2$1"];
    }
    else {
        NSLog(@"%@", error);
    }
   
    NSArray *html_code = @[
                           @"\"", @"'", @"&", @"<", @">", 
                           @"", @"¡", @"¢", @"£", @"¤", 
                           @"¥", @"¦", @"§", @"¨", @"©", 
                           @"ª", @"«", @"¬", @"", @"®", 
                           @"¯", @"°", @"±", @"²", @"³", 
                          
                           @"´", @"µ", @"¶", @"·", @"¸", 
                           @"¹", @"º", @"»", @"¼", @"½", 
                           @"¾", @"¿", @"×", @"÷", @"À", 
                           @"Á", @"Â", @"Ã", @"Ä", @"Å", 
                           @"Æ", @"Ç", @"È", @"É", @"Ê", 
                          
                           @"Ë", @"Ì", @"Í", @"Î", @"Ï", 
                           @"Ð", @"Ñ", @"Ò", @"Ó", @"Ô", 
                           @"Õ", @"Ö", @"Ø", @"Ù", @"Ú", 
                           @"Û", @"Ü", @"Ý", @"Þ", @"ß", 
                           @"à", @"á", @"â", @"ã", @"ä", 
                          
                           @"å", @"æ", @"ç", @"è", @"é", 
                           @"ê", @"ë", @"ì", @"í", @"î", 
                           @"ï", @"ð", @"ñ", @"ò", @"ó", 
                           @"ô", @"õ", @"ö", @"ø", @"ù", 
                           @"ú", @"û", @"ü", @"ý", @"þ", 
                          
                           @"ÿ", @"∀", @"∂", @"∃", @"∅", 
                           @"∇", @"∈", @"∉", @"∋", @"∏", 
                           @"∑", @"−", @"∗", @"√", @"∝", 
                           @"∞", @"∠", @"∧", @"∨", @"∩", 
                           @"∪", @"∫", @"∴", @"∼", @"≅", 
                          
                           @"≈", @"≠", @"≡", @"≤", @"≥", 
                           @"⊂", @"⊃", @"⊄", @"⊆", @"⊇", 
                           @"⊕", @"⊗", @"⊥", @"⋅", @"Α", 
                           @"Β", @"Γ", @"Δ", @"Ε", @"Ζ", 
                           @"Η", @"Θ", @"Ι", @"Κ", @"Λ", 
                          
                           @"Μ", @"Ν", @"Ξ", @"Ο", @"Π", 
                           @"Ρ", @"Σ", @"Τ", @"Υ", @"Φ", 
                           @"Χ", @"Ψ", @"Ω", @"α", @"β", 
                           @"γ", @"δ", @"ε", @"ζ", @"η", 
                           @"θ", @"ι", @"κ", @"λ", @"μ", 
                          
                           @"ν", @"ξ", @"ο", @"π", @"ρ", 
                           @"ς", @"σ", @"τ", @"υ", @"φ", 
                           @"χ", @"ψ", @"ω", @"ϑ", @"ϒ", 
                           @"ϖ", @"Œ", @"œ", @"Š", @"š", 
                           @"Ÿ", @"ƒ", @"ˆ", @"˜", @"", 
                          
                           @"", @"", @"", @"", @"", 
                           @"", @"–", @"—", @"‘", @"’", 
                           @"‚", @"“", @"”", @"„", @"†", 
                           @"‡", @"•", @"…", @"‰", @"′", 
                           @"″", @"‹", @"›", @"‾", @"€", 
                          
                           @"™", @"←", @"↑", @"→", @"↓", 
                           @"↔", @"↵", @"⌈", @"⌉", @"⌊", 
                           @"⌋", @"◊", @"♠", @"♣", @"♥", 
                           @"♦", 
                           ];
    NSArray *gc_code = @[
                      @"&quot;", @"&apos;", @"&amp;", @"&lt;", @"&gt;", 
                      @"&nbsp;", @"&iexcl;", @"&cent;", @"&pound;", @"&curren;", 
                      @"&yen;", @"&brvbar;", @"&sect;", @"&uml;", @"&copy;", 
                      @"&ordf;", @"&laquo;", @"&not;", @"&shy;", @"&reg;", 
                      @"&macr;", @"&deg;", @"&plusmn;", @"&sup2;", @"&sup3;", 
                     
                      @"&acute;", @"&micro;", @"&para;", @"&middot;", @"&cedil;", 
                      @"&sup1;", @"&ordm;", @"&raquo;", @"&frac14;", @"&frac12;", 
                      @"&frac34;", @"&iquest;", @"&times;", @"&divide;", @"&Agrave;", 
                      @"&Aacute;", @"&Acirc;", @"&Atilde;", @"&Auml;", @"&Aring;", 
                      @"&AElig;", @"&Ccedil;", @"&Egrave;", @"&Eacute;", @"&Ecirc;", 
                     
                      @"&Euml;", @"&Igrave;", @"&Iacute;", @"&Icirc;", @"&Iuml;", 
                      @"&ETH;", @"&Ntilde;", @"&Ograve;", @"&Oacute;", @"&Ocirc;", 
                      @"&Otilde;", @"&Ouml;", @"&Oslash;", @"&Ugrave;", @"&Uacute;", 
                      @"&Ucirc;", @"&Uuml;", @"&Yacute;", @"&THORN;", @"&szlig;", 
                      @"&agrave;", @"&aacute;", @"&acirc;", @"&atilde;", @"&auml;", 
                     
                      @"&aring;", @"&aelig;", @"&ccedil;", @"&egrave;", @"&eacute;", 
                      @"&ecirc;", @"&euml;", @"&igrave;", @"&iacute;", @"&icirc;", 
                      @"&iuml;", @"&eth;", @"&ntilde;", @"&ograve;", @"&oacute;", 
                      @"&ocirc;", @"&otilde;", @"&ouml;", @"&oslash;", @"&ugrave;", 
                      @"&uacute;", @"&ucirc;", @"&uuml;", @"&yacute;", @"&thorn;", 
                     
                      @"&yuml;", @"&forall;", @"&part;", @"&exists;", @"&empty;", 
                      @"&nabla;", @"&isin;", @"&notin;", @"&ni;", @"&prod;", 
                      @"&sum;", @"&minus;", @"&lowast;", @"&radic;", @"&prop;", 
                      @"&infin;", @"&ang;", @"&and;", @"&or;", @"&cap;", 
                      @"&cup;", @"&int;", @"&there4;", @"&sim;", @"&cong;", 
                     
                      @"&asymp;", @"&ne;", @"&equiv;", @"&le;", @"&ge;", 
                      @"&sub;", @"&sup;", @"&nsub;", @"&sube;", @"&supe;", 
                      @"&oplus;", @"&otimes;", @"&perp;", @"&sdot;", @"&Alpha;", 
                      @"&Beta;", @"&Gamma;", @"&Delta;", @"&Epsilon;", @"&Zeta;", 
                      @"&Eta;", @"&Theta;", @"&Iota;", @"&Kappa;", @"&Lambda;", 
                     
                      @"&Mu;", @"&Nu;", @"&Xi;", @"&Omicron;", @"&Pi;", 
                      @"&Rho;", @"&Sigma;", @"&Tau;", @"&Upsilon;", @"&Phi;", 
                      @"&Chi;", @"&Psi;", @"&Omega;", @"&alpha;", @"&beta;", 
                      @"&gamma;", @"&delta;", @"&epsilon;", @"&zeta;", @"&eta;", 
                      @"&theta;", @"&iota;", @"&kappa;", @"&lambda;", @"&mu;", 
                     
                      @"&nu;", @"&xi;", @"&omicron;", @"&pi;", @"&rho;", 
                      @"&sigmaf;", @"&sigma;", @"&tau;", @"&upsilon;", @"&phi;", 
                      @"&chi;", @"&psi;", @"&omega;", @"&thetasym;", @"&upsih;", 
                      @"&piv;", @"&OElig;", @"&oelig;", @"&Scaron;", @"&scaron;", 
                      @"&Yuml;", @"&fnof;", @"&circ;", @"&tilde;", @"&ensp;", 
                     
                      @"&emsp;", @"&thinsp;", @"&zwnj;", @"&zwj;", @"&lrm;", 
                      @"&rlm;", @"&ndash;", @"&mdash;", @"&lsquo;", @"&rsquo;", 
                      @"&sbquo;", @"&ldquo;", @"&rdquo;", @"&bdquo;", @"&dagger;", 
                      @"&Dagger;", @"&bull;", @"&hellip;", @"&permil;", @"&prime;", 
                      @"&Prime;", @"&lsaquo;", @"&rsaquo;", @"&oline;", @"&euro;", 
                     
                      @"&trade;", @"&larr;", @"&uarr;", @"&rarr;", @"&darr;", 
                      @"&harr;", @"&crarr;", @"&lceil;", @"&rceil;", @"&lfloor;", 
                      @"&rfloor;", @"&loz;", @"&spades;", @"&clubs;", @"&hearts;", 
                      @"&diams;", 
                      ];
//    NSArray *code_hex = @[
//                          @"&#34;", @"&#39;", @"&#38;", @"&#60;", @"&#62;", 
//                          @"&#160;", @"&#161;", @"&#162;", @"&#163;", @"&#164;", 
//                          @"&#165;", @"&#166;", @"&#167;", @"&#168;", @"&#169;", 
//                          @"&#170;", @"&#171;", @"&#172;", @"&#173;", @"&#174;", 
//                          @"&#175;", @"&#176;", @"&#177;", @"&#178;", @"&#179;", 
//                         
//                          @"&#180;", @"&#181;", @"&#182;", @"&#183;", @"&#184;", 
//                          @"&#185;", @"&#186;", @"&#187;", @"&#188;", @"&#189;", 
//                          @"&#190;", @"&#191;", @"&#215;", @"&#247;", @"&#192;", 
//                          @"&#193;", @"&#194;", @"&#195;", @"&#196;", @"&#197;", 
//                          @"&#198;", @"&#199;", @"&#200;", @"&#201;", @"&#202;", 
//                         
//                          @"&#203;", @"&#204;", @"&#205;", @"&#206;", @"&#207;", 
//                          @"&#208;", @"&#209;", @"&#210;", @"&#211;", @"&#212;", 
//                          @"&#213;", @"&#214;", @"&#216;", @"&#217;", @"&#218;", 
//                          @"&#219;", @"&#220;", @"&#221;", @"&#222;", @"&#223;", 
//                          @"&#224;", @"&#225;", @"&#226;", @"&#227;", @"&#228;", 
//                         
//                          @"&#229;", @"&#230;", @"&#231;", @"&#232;", @"&#233;", 
//                          @"&#234;", @"&#235;", @"&#236;", @"&#237;", @"&#238;", 
//                          @"&#239;", @"&#240;", @"&#241;", @"&#242;", @"&#243;", 
//                          @"&#244;", @"&#245;", @"&#246;", @"&#248;", @"&#249;", 
//                          @"&#250;", @"&#251;", @"&#252;", @"&#253;", @"&#254;", 
//                         
//                          @"&#255;", @"&#8704;", @"&#8706;", @"&#8707;", @"&#8709;", 
//                          @"&#8711;", @"&#8712;", @"&#8713;", @"&#8715;", @"&#8719;", 
//                          @"&#8721;", @"&#8722;", @"&#8727;", @"&#8730;", @"&#8733;", 
//                          @"&#8734;", @"&#8736;", @"&#8743;", @"&#8744;", @"&#8745;", 
//                          @"&#8746;", @"&#8747;", @"&#8756;", @"&#8764;", @"&#8773;", 
//                         
//                          @"&#8776;", @"&#8800;", @"&#8801;", @"&#8804;", @"&#8805;", 
//                          @"&#8834;", @"&#8835;", @"&#8836;", @"&#8838;", @"&#8839;", 
//                          @"&#8853;", @"&#8855;", @"&#8869;", @"&#8901;", @"&#913;", 
//                          @"&#914;", @"&#915;", @"&#916;", @"&#917;", @"&#918;", 
//                          @"&#919;", @"&#920;", @"&#921;", @"&#922;", @"&#923;", 
//                         
//                          @"&#924;", @"&#925;", @"&#926;", @"&#927;", @"&#928;", 
//                          @"&#929;", @"&#931;", @"&#932;", @"&#933;", @"&#934;", 
//                          @"&#935;", @"&#936;", @"&#937;", @"&#945;", @"&#946;", 
//                          @"&#947;", @"&#948;", @"&#949;", @"&#950;", @"&#951;", 
//                          @"&#952;", @"&#953;", @"&#954;", @"&#923;", @"&#956;", 
//                         
//                          @"&#925;", @"&#958;", @"&#959;", @"&#960;", @"&#961;", 
//                          @"&#962;", @"&#963;", @"&#964;", @"&#965;", @"&#966;", 
//                          @"&#967;", @"&#968;", @"&#969;", @"&#977;", @"&#978;", 
//                          @"&#982;", @"&#338;", @"&#339;", @"&#352;", @"&#353;", 
//                          @"&#376;", @"&#402;", @"&#710;", @"&#732;", @"&#8194;", 
//                         
//                          @"&#8195;", @"&#8201;", @"&#8204;", @"&#8205;", @"&#8206;", 
//                          @"&#8207;", @"&#8211;", @"&#8212;", @"&#8216;", @"&#8217;", 
//                          @"&#8218;", @"&#8220;", @"&#8221;", @"&#8222;", @"&#8224;", 
//                          @"&#8225;", @"&#8226;", @"&#8230;", @"&#8240;", @"&#8242;", 
//                          @"&#8243;", @"&#8249;", @"&#8250;", @"&#8254;", @"&#8364;", 
//                         
//                          @"&#8482;", @"&#8592;", @"&#8593;", @"&#8594;", @"&#8595;", 
//                          @"&#8596;", @"&#8629;", @"&#8968;", @"&#8969;", @"&#8970;", 
//                          @"&#8971;", @"&#9674;", @"&#9824;", @"&#9827;", @"&#9829;", 
//                          @"&#9830;", 
//                          ];
   
    NSInteger gc_idx = 0;
    for (NSString *gc_obj in gc_code) {
        gc_str = [gc_str stringByReplacingOccurrencesOfString:(NSString *)gc_obj withString:html_code[gc_idx]];
        gc_idx ++;
    }
    return gc_str;
}

// 工商税号
- (BOOL)is_Tax_No {
    NSString *emailRegex = @"[0-9]\\d{13}([0-9]|X)$";
    NSPredicate *email_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [email_test evaluateWithObject:self];
}

@end
posted @ 2024-08-05 16:09  CH520  阅读(6)  评论(0编辑  收藏  举报