天天看点

iOS开发笔记- 判断是否是数字

+(BOOL)isNumber:(NSString *)str{

    NSRegularExpression *tNumRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"[0-9]" options:NSRegularExpressionCaseInsensitive error:nil];

    int tLetterMatchCount = [tNumRegularExpression numberOfMatchesInString:str options:NSMatchingReportProgress range:NSMakeRange(0, str.length)];

    if(tLetterMatchCount>=1){

        return YES;

    }else{

        return NO;

    }

}