1.判断输入框的内容是否是数字
-(BOOL)isNumText:(NSString *)str{ NSString * regex = @"^[0-9]*$"; NSPredicate * pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; BOOL isMatch = [pred evaluateWithObject:str]; if (isMatch) { return YES; }else{ return NO; } }
原文链接:https://www.f2er.com/regex/362288.html