码迷,mamicode.com
首页 > 其他好文 > 详细

常用正则.备份一下

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

标签:blog   ar   sp   for   div   on   log   as   tt   

?

+(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];
}

?

常用正则.备份一下

标签:blog   ar   sp   for   div   on   log   as   tt   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!