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 
- (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
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.

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 
- (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 = @[
                      @""", @"'", @"&", @"<", @">", 
                      @" ", @"¡", @"¢", @"£", @"¤", 
                      @"¥", @"¦", @"§", @"¨", @"©", 
                      @"ª", @"«", @"¬", @"­", @"®", 
                      @"¯", @"°", @"±", @"²", @"³", 
                     
                      @"´", @"µ", @"¶", @"·", @"¸", 
                      @"¹", @"º", @"»", @"¼", @"½", 
                      @"¾", @"¿", @"×", @"÷", @"À", 
                      @"Á", @"Â", @"Ã", @"Ä", @"Å", 
                      @"Æ", @"Ç", @"È", @"É", @"Ê", 
                     
                      @"Ë", @"Ì", @"Í", @"Î", @"Ï", 
                      @"Ð", @"Ñ", @"Ò", @"Ó", @"Ô", 
                      @"Õ", @"Ö", @"Ø", @"Ù", @"Ú", 
                      @"Û", @"Ü", @"Ý", @"Þ", @"ß", 
                      @"à", @"á", @"â", @"ã", @"ä", 
                     
                      @"å", @"æ", @"ç", @"è", @"é", 
                      @"ê", @"ë", @"ì", @"í", @"î", 
                      @"ï", @"ð", @"ñ", @"ò", @"ó", 
                      @"ô", @"õ", @"ö", @"ø", @"ù", 
                      @"ú", @"û", @"ü", @"ý", @"þ", 
                     
                      @"ÿ", @"∀", @"∂", @"&exists;", @"∅", 
                      @"∇", @"∈", @"∉", @"∋", @"∏", 
                      @"∑", @"−", @"∗", @"√", @"∝", 
                      @"∞", @"∠", @"∧", @"∨", @"∩", 
                      @"∪", @"∫", @"∴", @"∼", @"≅", 
                     
                      @"≈", @"≠", @"≡", @"≤", @"≥", 
                      @"⊂", @"⊃", @"⊄", @"⊆", @"⊇", 
                      @"⊕", @"⊗", @"⊥", @"⋅", @"Α", 
                      @"Β", @"Γ", @"Δ", @"Ε", @"Ζ", 
                      @"Η", @"Θ", @"Ι", @"Κ", @"Λ", 
                     
                      @"Μ", @"Ν", @"Ξ", @"Ο", @"Π", 
                      @"Ρ", @"Σ", @"Τ", @"Υ", @"Φ", 
                      @"Χ", @"Ψ", @"Ω", @"α", @"β", 
                      @"γ", @"δ", @"ε", @"ζ", @"η", 
                      @"θ", @"ι", @"κ", @"λ", @"μ", 
                     
                      @"ν", @"ξ", @"ο", @"π", @"ρ", 
                      @"ς", @"σ", @"τ", @"υ", @"φ", 
                      @"χ", @"ψ", @"ω", @"ϑ", @"ϒ", 
                      @"ϖ", @"Œ", @"œ", @"Š", @"š", 
                      @"Ÿ", @"ƒ", @"ˆ", @"˜", @" ", 
                     
                      @" ", @" ", @"", @"", @"‎", 
                      @"‏", @"–", @"—", @"‘", @"’", 
                      @"‚", @"“", @"”", @"„", @"†", 
                      @"‡", @"•", @"…", @"‰", @"′", 
                      @"″", @"‹", @"›", @"‾", @"€", 
                     
                      @"™", @"←", @"↑", @"→", @"↓", 
                      @"↔", @"↵", @"⌈", @"⌉", @"⌊", 
                      @"⌋", @"◊", @"♠", @"♣", @"♥", 
                      @"♦", 
                      ];
//    NSArray *code_hex = @[
//                          @""", @"'", @"&", @"<", @">", 
//                          @" ", @"¡", @"¢", @"£", @"¤", 
//                          @"¥", @"¦", @"§", @"¨", @"©", 
//                          @"ª", @"«", @"¬", @"­", @"®", 
//                          @"¯", @"°", @"±", @"²", @"³", 
//                         
//                          @"´", @"µ", @"¶", @"·", @"¸", 
//                          @"¹", @"º", @"»", @"¼", @"½", 
//                          @"¾", @"¿", @"×", @"÷", @"À", 
//                          @"Á", @"Â", @"Ã", @"Ä", @"Å", 
//                          @"Æ", @"Ç", @"È", @"É", @"Ê", 
//                         
//                          @"Ë", @"Ì", @"Í", @"Î", @"Ï", 
//                          @"Ð", @"Ñ", @"Ò", @"Ó", @"Ô", 
//                          @"Õ", @"Ö", @"Ø", @"Ù", @"Ú", 
//                          @"Û", @"Ü", @"Ý", @"Þ", @"ß", 
//                          @"à", @"á", @"â", @"ã", @"ä", 
//                         
//                          @"å", @"æ", @"ç", @"è", @"é", 
//                          @"ê", @"ë", @"ì", @"í", @"î", 
//                          @"ï", @"ð", @"ñ", @"ò", @"ó", 
//                          @"ô", @"õ", @"ö", @"ø", @"ù", 
//                          @"ú", @"û", @"ü", @"ý", @"þ", 
//                         
//                          @"ÿ", @"∀", @"∂", @"∃", @"∅", 
//                          @"∇", @"∈", @"∉", @"∋", @"∏", 
//                          @"∑", @"−", @"∗", @"√", @"∝", 
//                          @"∞", @"∠", @"∧", @"∨", @"∩", 
//                          @"∪", @"∫", @"∴", @"∼", @"≅", 
//                         
//                          @"≈", @"≠", @"≡", @"≤", @"≥", 
//                          @"⊂", @"⊃", @"⊄", @"⊆", @"⊇", 
//                          @"⊕", @"⊗", @"⊥", @"⋅", @"Α", 
//                          @"Β", @"Γ", @"Δ", @"Ε", @"Ζ", 
//                          @"Η", @"Θ", @"Ι", @"Κ", @"Λ", 
//                         
//                          @"Μ", @"Ν", @"Ξ", @"Ο", @"Π", 
//                          @"Ρ", @"Σ", @"Τ", @"Υ", @"Φ", 
//                          @"Χ", @"Ψ", @"Ω", @"α", @"β", 
//                          @"γ", @"δ", @"ε", @"ζ", @"η", 
//                          @"θ", @"ι", @"κ", @"Λ", @"μ", 
//                         
//                          @"Ν", @"ξ", @"ο", @"π", @"ρ", 
//                          @"ς", @"σ", @"τ", @"υ", @"φ", 
//                          @"χ", @"ψ", @"ω", @"ϑ", @"ϒ", 
//                          @"ϖ", @"Œ", @"œ", @"Š", @"š", 
//                          @"Ÿ", @"ƒ", @"ˆ", @"˜", @" ", 
//                         
//                          @" ", @" ", @"", @"", @"‎", 
//                          @"‏", @"–", @"—", @"‘", @"’", 
//                          @"‚", @"“", @"”", @"„", @"†", 
//                          @"‡", @"•", @"…", @"‰", @"′", 
//                          @"″", @"‹", @"›", @"‾", @"€", 
//                         
//                          @"™", @"←", @"↑", @"→", @"↓", 
//                          @"↔", @"↵", @"⌈", @"⌉", @"⌊", 
//                          @"⌋", @"◊", @"♠", @"♣", @"♥", 
//                          @"♦", 
//                          ];
   
    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
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 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.
  • 192.
  • 193.
  • 194.
  • 195.
  • 196.
  • 197.
  • 198.
  • 199.
  • 200.
  • 201.
  • 202.
  • 203.
  • 204.
  • 205.
  • 206.
  • 207.
  • 208.
  • 209.
  • 210.
  • 211.
  • 212.
  • 213.
  • 214.
  • 215.
  • 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.
  • 247.
  • 248.
  • 249.
  • 250.
  • 251.
  • 252.
  • 253.
  • 254.
  • 255.
  • 256.
  • 257.
  • 258.
  • 259.
  • 260.
  • 261.
  • 262.
  • 263.
  • 264.
  • 265.
  • 266.
  • 267.
  • 268.
  • 269.
  • 270.
  • 271.
  • 272.
  • 273.
  • 274.
  • 275.
  • 276.
  • 277.
  • 278.
  • 279.
  • 280.
  • 281.
  • 282.
  • 283.
  • 284.
  • 285.
  • 286.
  • 287.
  • 288.
  • 289.
  • 290.
  • 291.
  • 292.
  • 293.
  • 294.
  • 295.
  • 296.
  • 297.
  • 298.
  • 299.
  • 300.
  • 301.
  • 302.
  • 303.
  • 304.
  • 305.
  • 306.
  • 307.
  • 308.
  • 309.
  • 310.
  • 311.
  • 312.
  • 313.
  • 314.
  • 315.
  • 316.
  • 317.
  • 318.
  • 319.
  • 320.
  • 321.
  • 322.
  • 323.
  • 324.
  • 325.
  • 326.
  • 327.
  • 328.
  • 329.
  • 330.
  • 331.
  • 332.
  • 333.
  • 334.
  • 335.
  • 336.
  • 337.
  • 338.
  • 339.
  • 340.
  • 341.
  • 342.
  • 343.
  • 344.
  • 345.
  • 346.
  • 347.
  • 348.
  • 349.
  • 350.
  • 351.
  • 352.
  • 353.
  • 354.
  • 355.
  • 356.
  • 357.
  • 358.
  • 359.
  • 360.
  • 361.
  • 362.
  • 363.
  • 364.
  • 365.
  • 366.
  • 367.
  • 368.
  • 369.
  • 370.
  • 371.
  • 372.
  • 373.
  • 374.
  • 375.
  • 376.
  • 377.
  • 378.
  • 379.
  • 380.
  • 381.
  • 382.
  • 383.
  • 384.
  • 385.
  • 386.
  • 387.
  • 388.
  • 389.
  • 390.
  • 391.
  • 392.
  • 393.
  • 394.
  • 395.
  • 396.
  • 397.
  • 398.
  • 399.
  • 400.
  • 401.
  • 402.
  • 403.
  • 404.
  • 405.
  • 406.
  • 407.
  • 408.
  • 409.
  • 410.


作者: CH520