美文网首页
OC 验证金额的正则表达式方法

OC 验证金额的正则表达式方法

作者: WARRON | 来源:发表于2017-01-10 17:29 被阅读45次

//

  • (BOOL) isPrice:(NSString *) price {
    NSString *format =@"([1-9]([0-9]+)?(.[0-9]{1,2})?$)|((0){1}$)|(^[0-9].0-9?$)";
    NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", format];
    if ([regextest evaluateWithObject:price] == YES)
    return YES;
    else
    return NO;
    }

相关文章

网友评论

      本文标题:OC 验证金额的正则表达式方法

      本文链接:https://www.haomeiwen.com/subject/hntlbttx.html