使用调用函数
if([self deptNumInputShouldNumber])
NSLog(@"输入的不是全数字呢");
//结果:输入的不是全数字呢
判断输入的是否为全汉字
- (BOOL) deptNameInputShouldChinese
{
NSString *regex = @"[\u4e00-\u9fa5]+";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
if (![pred evaluateWithObject:self.SearchLabel.text]) {
return YES;
}
return NO;
}
判断输入的是否为全数字
- (BOOL) deptNumInputShouldNumber
{
NSString *regex =@"[0-9]*";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
if (![pred evaluateWithObject:self.SearchLabel.text]) {
return YES;
}
return NO;
}
判断输入的是否为全字母
- (BOOL) deptPassInputShouldAlpha
{
NSString *regex =@"[a-zA-Z]*";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
if (![pred evaluateWithObject:self.SearchLabel.text]) {
return YES;
}
return NO;
}