首页 > 其他 > 详细

常用正则.备份一下

时间:2014-11-17 17:31:13      阅读:212      评论:0      收藏:0      [点我收藏+]
?

+(BOOL) isValidateMobile:(NSString *)mobile
{
    //手机号以13, 15,18开头,八个 \d 数字字符
    NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    //    NSLog(@"phoneTest is %@",phoneTest);
    return [phoneTest evaluateWithObject:mobile];
}

??
- (BOOL)isPhoneNumber
{
    NSString *Regex = @"(13[0-9]|14[57]|15[0-9]|18[0235-9])\\d{8}";
    NSPredicate *mobileTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
    return [mobileTest evaluateWithObject:self];
}

?
?

// 商品条码标准位13位
- (BOOL)checkBarcode:(NSString *)_text
{
    NSString *regex = @"^\\d{13}$";
    NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    return [test evaluateWithObject:_text];
}

?

常用正则.备份一下

原文:http://www.cnblogs.com/jz319/p/4103917.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!