///正则判断元素是否是数字

  • (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

相关文章:

  • 2021-10-05
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案