///正则判断元素是否是数字
- (BOOL)inputShouldNumber:(NSString *)inputString {
if (inputString.length == 0)
return NO;
NSString *regex = @"^[0-9]+([.]{0,1}[0-9]+){0,1}$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [pred evaluateWithObject:inputString];
}
特别鸣谢:
http://www.cocoachina.com/bbs/read.php?tid-1706238.html