//判断是否是纯字母
- (BOOL)isPureCharacters:(NSString *)string
{
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet letterCharacterSet]];
if(string.length > 0)
{
return NO;
}
return YES;
}
//判断是否是纯数字
- (BOOL)isPureNum:(NSString *)string
{
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
if(string.length > 0)
{
return NO;
}
return YES;
}
//判断是否包含连续的数组或字母,yes为包含
- (BOOL)rangeString:(NSString *)string {
BOOL result = NO;
for (int i = 0; i < string.length; i++) {
if (string.length - i < 4 ) {
break;
}
NSString *newStr = [string substringWithRange:NSMakeRange(i, 4)];
if ([self isPureCharacters:newStr] || [self isPureNum:newStr]) {
NSLog(@"%@",newStr);
result = YES;
break;
}
}
return result;
}