iOS判断是否是中文或者英文

 NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string];
    NSCharacterSet *nameCharacters = [[NSCharacterSet
                                       characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"] invertedSet];
    NSRange userNameRange = [toBeString rangeOfCharacterFromSet:nameCharacters];
    if (userNameRange.location != NSNotFound) {
        
        NSLog(@"包含特殊字符");
        return NO;
    }

你可能感兴趣的:(正则表达式判断)