iOS-開源代碼(一些正則校驗席纽,判斷郵箱捏悬,手機號碼,車牌號润梯,身份證號过牙,網(wǎng)址甥厦,賬號,密碼寇钉,ip刀疙,去掉html格式,工商稅號等扫倡。)

直接給大家po出來源碼吧G怼!謝謝大家支持:

  • NSString+STRegex.h 源碼
//
//  NSString+STRegex.h
//  NSString+STRegex
//
//  Created by yls on 14-1-15.
//  Copyright (c) 2014年 yls. All rights reserved.
//
// http://git.oschina.net/yanglishuan/NSString-STRegex
// emailto: 2008.yls@163.com
// QQ: 603291699
//

#import <Foundation/Foundation.h>

@interface NSString (STRegex)

///////////////////////////// 正則表達式相關  ///////////////////////////////

/** 郵箱驗證 */
- (BOOL)isValidEmail;

/** 手機號碼驗證 */
- (BOOL)isValidPhoneNum;

/** 車牌號驗證 */
- (BOOL)isValidCarNo;

/** 網(wǎng)址驗證 */
- (BOOL)isValidUrl;

/** 郵政編碼 */
- (BOOL)isValidPostalcode;

/** 純漢字 */
- (BOOL)isValidChinese;



/**
 @brief     是否符合IP格式撵溃,xxx.xxx.xxx.xxx
 */
- (BOOL)isValidIP;

/** 身份證驗證 refer to http://blog.csdn.net/afyzgh/article/details/16965107*/
- (BOOL)isValidIdCardNum;

/**
 @brief     是否符合最小長度疚鲤、最長長度,是否包含中文,數(shù)字缘挑,字母集歇,其他字符,首字母是否可以為數(shù)字
 @param     minLenth 賬號最小長度
 @param     maxLenth 賬號最長長度
 @param     containChinese 是否包含中文
 @param     containDigtal   包含數(shù)字
 @param     containLetter   包含字母
 @param     containOtherCharacter   其他字符
 @param     firstCannotBeDigtal 首字母不能為數(shù)字
 @return    正則驗證成功返回YES, 否則返回NO
 */
- (BOOL)isValidWithMinLenth:(NSInteger)minLenth
                   maxLenth:(NSInteger)maxLenth
             containChinese:(BOOL)containChinese
              containDigtal:(BOOL)containDigtal
              containLetter:(BOOL)containLetter
      containOtherCharacter:(NSString *)containOtherCharacter
        firstCannotBeDigtal:(BOOL)firstCannotBeDigtal;

/** 去掉兩端空格和換行符 */
- (NSString *)stringByTrimmingBlank;

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

/** 工商稅號 */
- (BOOL)isValidTaxNo;

@end

  • NSString+STRegex.m 源碼
//
//  NSString+STRegex.m
//  NSString+STRegex
//
//  Created by yls on 14-1-15.
//  Copyright (c) 2014年 yls. All rights reserved.
//
//  http://git.oschina.net/yanglishuan/NSString-STRegex
// emailto: 2008.yls@163.com
// QQ: 603291699
//

#import "NSString+STRegex.h"

@implementation NSString (STRegex)

///////////////////////////// 正則表達式相關  ///////////////////////////////

- (BOOL)isValidateWithRegex:(NSString *)regex
{
    NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [pre evaluateWithObject:self];
}

/* 郵箱驗證 MODIFIED BY HELENSONG */
- (BOOL)isValidEmail
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:self];
}

/* 手機號碼驗證 MODIFIED BY HELENSONG */
- (BOOL)isValidPhoneNum
{
    //手機號以13卖哎, 14,15删性,17亏娜,18,19開頭蹬挺,八個 \d 數(shù)字字符
    NSString *phoneRegex = @"^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[0-9])[0-9]{8}$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:self];
}

/* 車牌號驗證 MODIFIED BY HELENSONG */
- (BOOL)isValidCarNo
{
    NSString *carRegex = @"^[A-Za-z]{1}[A-Za-z_0-9]{5}$";
    NSPredicate *carTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",carRegex];
    return [carTest evaluateWithObject:self];
}

/** 網(wǎng)址驗證 */
- (BOOL)isValidUrl
{
    NSString *regex = @"^((http)|(https))+:[^\\s]+\\.[^\\s]*$";
    return [self isValidateWithRegex:regex];
}

/** 郵政編碼 */
- (BOOL)isValidPostalcode {
    NSString *phoneRegex = @"^[0-8]\\d{5}(?!\\d)$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:self];
}

/** 純漢字 */
- (BOOL)isValidChinese;
{
    NSString *phoneRegex = @"^[\u4e00-\u9fa5]+$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:self];
}

- (BOOL)isValidIP;
{
    NSString *regex = [NSString stringWithFormat:@"^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$"];
    NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    BOOL rc = [pre evaluateWithObject:self];
    
    if (rc) {
        NSArray *componds = [self componentsSeparatedByString:@","];
        
        BOOL v = YES;
        for (NSString *s in componds) {
            if (s.integerValue > 255) {
                v = NO;
                break;
            }
        }
        
        return v;
    }
    
    return NO;
}

/** 身份證驗證 refer to http://blog.csdn.net/afyzgh/article/details/16965107 */
- (BOOL)isValidIdCardNum
{
    NSString *value = [self copy];
    value = [value stringByReplacingOccurrencesOfString:@"X" withString:@"x"];
    value = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    int length = 0;
    if (!value) {
        return NO;
    }else {
        length = (int)value.length;
        if (length != 15 && length !=18) {
            return NO;
        }
    }
    // 省份代碼
    NSArray *areasArray =@[@"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 *valueStart2 = [value substringToIndex:2];
    BOOL areaFlag = NO;
    for (NSString *areaCode in areasArray) {
        if ([areaCode isEqualToString:valueStart2]) {
            areaFlag = YES;
            break;
        }
    }
    if (!areaFlag) {
        return NO;
    }
    NSRegularExpression *regularExpression;
    NSUInteger numberofMatch;
    int year = 0;
    switch (length) {
        case 15:
            year = [value substringWithRange:NSMakeRange(6,2)].intValue +1900;
            if (year % 4 ==0 || (year % 100 ==0 && 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:value options:NSMatchingReportProgress range:NSMakeRange(0, value.length)];
            if(numberofMatch > 0) {
                return YES;
            }else {
                return NO;
            }
        case 18:
            year = [value substringWithRange:NSMakeRange(6,4)].intValue;
            if (year % 4 ==0 || (year % 100 ==0 && 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:value options:NSMatchingReportProgress range:NSMakeRange(0, value.length)];
            if(numberofMatch > 0) {
                int S = ([value substringWithRange:NSMakeRange(0,1)].intValue + [value substringWithRange:NSMakeRange(10,1)].intValue) *7 + ([value substringWithRange:NSMakeRange(1,1)].intValue + [value substringWithRange:NSMakeRange(11,1)].intValue) *9 + ([value substringWithRange:NSMakeRange(2,1)].intValue + [value substringWithRange:NSMakeRange(12,1)].intValue) *10 + ([value substringWithRange:NSMakeRange(3,1)].intValue + [value substringWithRange:NSMakeRange(13,1)].intValue) *5 + ([value substringWithRange:NSMakeRange(4,1)].intValue + [value substringWithRange:NSMakeRange(14,1)].intValue) *8 + ([value substringWithRange:NSMakeRange(5,1)].intValue + [value substringWithRange:NSMakeRange(15,1)].intValue) *4 + ([value substringWithRange:NSMakeRange(6,1)].intValue + [value substringWithRange:NSMakeRange(16,1)].intValue) *2 + [value substringWithRange:NSMakeRange(7,1)].intValue *1 + [value substringWithRange:NSMakeRange(8,1)].intValue *6 + [value substringWithRange:NSMakeRange(9,1)].intValue *3;
                int Y = S % 11;
                NSString *M = @"F";
                NSString *JYM = @"10X98765432";
                M = [JYM substringWithRange:NSMakeRange(Y,1)]; // 判斷校驗位
                if ([M isEqualToString:[[value substringWithRange:NSMakeRange(17,1)] uppercaseString]]) {
                    return YES;// 檢測ID的校驗位
                }else {
                    return NO;
                }
            }else {
                return NO;
            }
            
        default:
            return NO;
    }
    return NO;
}

- (BOOL)isValidWithMinLenth:(NSInteger)minLenth
                   maxLenth:(NSInteger)maxLenth
             containChinese:(BOOL)containChinese
              containDigtal:(BOOL)containDigtal
              containLetter:(BOOL)containLetter
      containOtherCharacter:(NSString *)containOtherCharacter
        firstCannotBeDigtal:(BOOL)firstCannotBeDigtal;
{
    BOOL rc = YES;
    if (firstCannotBeDigtal) {
        NSString *regex = @"^[0-9]+.*";
        NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
        rc = [pre evaluateWithObject:self];
        if (rc) {
            return NO;
        }
    }
    
    NSString *hanzi = containChinese ? @"\u4e00-\u9fa5" : @"";
    NSString *digtalRegex = containDigtal ? @"0-9" : @"";
    NSString *containOtherCharacterRegex = containOtherCharacter ? containOtherCharacter : @"";
    NSString *characterRegex = [NSString stringWithFormat:@"[%@A-Za-z%@%@]", hanzi, digtalRegex, containOtherCharacterRegex];
    NSString *regex = [NSString stringWithFormat:@"%@{%@,%@}", characterRegex, @(minLenth), @(maxLenth)];
    NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    return [pre evaluateWithObject:self];
}

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

/** 去掉html格式 */
- (NSString *)removeHtmlFormat;
{
    NSString *str = [NSString stringWithFormat:@"%@", self];
    
    NSError *error;
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"<[^>]*>" options:NSRegularExpressionCaseInsensitive error:&error];
    if (!error) {
        str = [regex stringByReplacingMatchesInString:str options:0 range:NSMakeRange(0, str.length) withTemplate:@"$2$1"];
    } else {
        NSLog(@"%@", error);
    }
    
    NSArray *html_code = @[
                           @"\"", @"'", @"&", @"<", @">",
                           @"", @"?", @"¢", @"£", @"¤",
                           @"¥", @"|", @"§", @"¨", @"?",
                           @"a", @"?", @"?", @"", @"?",
                           @"ˉ", @"°", @"±", @"2", @"3",
                           
                           @"′", @"μ", @"?", @"·", @"?",
                           @"1", @"o", @"?", @"?", @"?",
                           @"?", @"?", @"×", @"÷", @"à",
                           @"á", @"?", @"?", @"?", @"?",
                           @"?", @"?", @"è", @"é", @"ê",
                           
                           @"?", @"ì", @"í", @"?", @"?",
                           @"D", @"?", @"ò", @"ó", @"?",
                           @"?", @"?", @"?", @"ù", @"ú",
                           @"?", @"ü", @"Y", @"T", @"?",
                           @"à", @"á", @"a", @"?", @"?",
                           
                           @"?", @"?", @"?", @"è", @"é",
                           @"ê", @"?", @"ì", @"í", @"?",
                           @"?", @"e", @"?", @"ò", @"ó",
                           @"?", @"?", @"?", @"?", @"ù",
                           @"ú", @"?", @"ü", @"y", @"t",
                           
                           @"?", @"?", @"?", @"?", @"?",
                           @"?", @"∈", @"?", @"?", @"∏",
                           @"∑", @"?", @"?", @"√", @"∝",
                           @"∞", @"∠", @"∧", @"∨", @"∩",
                           @"∪", @"∫", @"∴", @"~", @"?",
                           
                           @"≈", @"≠", @"≡", @"≤", @"≥",
                           @"?", @"?", @"?", @"?", @"?",
                           @"⊕", @"?", @"⊥", @"?", @"Α",
                           @"Β", @"Γ", @"Δ", @"Ε", @"Ζ",
                           @"Η", @"Θ", @"Ι", @"Κ", @"Λ",
                           
                           @"Μ", @"Ν", @"Ξ", @"Ο", @"Π",
                           @"Ρ", @"Σ", @"Τ", @"Υ", @"Φ",
                           @"Χ", @"Ψ", @"Ω", @"α", @"β",
                           @"γ", @"δ", @"ε", @"ζ", @"η",
                           @"θ", @"ι", @"κ", @"λ", @"μ",
                           
                           @"ν", @"ξ", @"ο", @"π", @"ρ",
                           @"?", @"σ", @"τ", @"υ", @"φ",
                           @"χ", @"ψ", @"ω", @"?", @"?",
                           @"?", @"?", @"?", @"?", @"?",
                           @"?", @"?", @"?", @"?", @"",
                           
                           @"", @"", @"", @"", @"",
                           @"", @"–", @"—", @"‘", @"’",
                           @"?", @"“", @"”", @"?", @"?",
                           @"?", @"?", @"…", @"‰", @"′",
                           @"″", @"?", @"?", @" ̄", @"€",
                           
                           @"?", @"←", @"↑", @"→", @"↓",
                           @"?", @"?", @"?", @"?", @"?",
                           @"?", @"?", @"?", @"?", @"?",
                           @"?",
                           ];
    NSArray *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 idx = 0;
    for (NSString *obj in code) {
        str = [str stringByReplacingOccurrencesOfString:(NSString *)obj withString:html_code[idx]];
        idx++;
    }
    return str;
}

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

@end

有問題請大家隨時指正维贺,交流,一起溝通學習0桶铩K萜!

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末榕茧,一起剝皮案震驚了整個濱河市垃沦,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌用押,老刑警劉巖肢簿,帶你破解...
    沈念sama閱讀 206,378評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異蜻拨,居然都是意外死亡池充,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,356評論 2 382
  • 文/潘曉璐 我一進店門缎讼,熙熙樓的掌柜王于貴愁眉苦臉地迎上來收夸,“玉大人,你說我怎么就攤上這事血崭∥韵В” “怎么了厘灼?”我有些...
    開封第一講書人閱讀 152,702評論 0 342
  • 文/不壞的土叔 我叫張陵,是天一觀的道長序苏。 經(jīng)常有香客問我手幢,道長,這世上最難降的妖魔是什么忱详? 我笑而不...
    開封第一講書人閱讀 55,259評論 1 279
  • 正文 為了忘掉前任围来,我火速辦了婚禮,結(jié)果婚禮上匈睁,老公的妹妹穿的比我還像新娘监透。我一直安慰自己,他們只是感情好航唆,可當我...
    茶點故事閱讀 64,263評論 5 371
  • 文/花漫 我一把揭開白布胀蛮。 她就那樣靜靜地躺著,像睡著了一般糯钙。 火紅的嫁衣襯著肌膚如雪粪狼。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,036評論 1 285
  • 那天任岸,我揣著相機與錄音再榄,去河邊找鬼。 笑死享潜,一個胖子當著我的面吹牛困鸥,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播剑按,決...
    沈念sama閱讀 38,349評論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼疾就,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了艺蝴?” 一聲冷哼從身側(cè)響起猬腰,我...
    開封第一講書人閱讀 36,979評論 0 259
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎猜敢,沒想到半個月后漆诽,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,469評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡锣枝,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 35,938評論 2 323
  • 正文 我和宋清朗相戀三年厢拭,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片撇叁。...
    茶點故事閱讀 38,059評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡供鸠,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出陨闹,到底是詐尸還是另有隱情楞捂,我是刑警寧澤薄坏,帶...
    沈念sama閱讀 33,703評論 4 323
  • 正文 年R本政府宣布,位于F島的核電站寨闹,受9級特大地震影響胶坠,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜繁堡,卻給世界環(huán)境...
    茶點故事閱讀 39,257評論 3 307
  • 文/蒙蒙 一沈善、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧椭蹄,春花似錦闻牡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,262評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至翼馆,卻和暖如春割以,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背应媚。 一陣腳步聲響...
    開封第一講書人閱讀 31,485評論 1 262
  • 我被黑心中介騙來泰國打工严沥, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人珍特。 一個月前我還...
    沈念sama閱讀 45,501評論 2 354
  • 正文 我出身青樓祝峻,卻偏偏與公主長得像魔吐,于是被迫代替她去往敵國和親扎筒。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 42,792評論 2 345

推薦閱讀更多精彩內(nèi)容