#define kCharacterAndNumber @"0123456789abcdefghijklmnopqrstuvwxyz/n"
// 字符串中含有数字和字母个数
- (NSInteger)countForNumberAndCharactersInString:(NSString *)string
{
NSInteger count = 0;
NSCharacterSet * charSet;
charSet = [[NSCharacterSet characterSetWithCharactersInString:kCharacterAndNumber] invertedSet];
for(int i = 0; i < [string length]; ++i) {
NSString * tempStr = [string substringWithRange:NSMakeRange(i, 1)];
NSString * filtered = [[tempStr componentsSeparatedByCharactersInSet:charSet] componentsJoinedByString:@""];
if([tempStr isEqualToString:filtered]){
count++;
};
}
return count;
}