是否为纯数字
- (BOOL)isPureDigital:(NSString *)string {
if (string.length<1) {
return NO;
}
NSString regex =@"[0-9]";
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pre evaluateWithObject: string];
}
是否为纯字母
- (BOOL)isPureLetters:(NSString *)string {
if (string.length<1) {
return NO;
}
NSString regex = @"[a-zA-Z]";
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pre evaluateWithObject: string];
}
是否为纯汉字
- (BOOL)isPureChineseCharacters:(NSString *)string {
if (string.length<1) {
return NO;
}
NSString *regex = @"[\u4e00-\u9fa5]+";
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pre evaluateWithObject: string];
}
是否为字母或数字
- (BOOL)isLettersOrDigital:(NSString *)string {
if (string.length<1) {
return NO;
}
NSString regex =@"[a-zA-Z0-9]";
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pre evaluateWithObject: string];
}
是否为大写字母
- (BOOL)isCapitalLetters:(NSString *)string {
if (string.length<1) {
return NO;
}
NSString regex =@"[A-Z]";
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pre evaluateWithObject: string];
}
是否为小写字母
- (BOOL)isLowercaseLetters:(NSString *)string {
if (string.length<1) {
return NO;
}
NSString regex =@"[a-z]";
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pre evaluateWithObject: string];
}