码迷,mamicode.com
首页 > 移动开发 > 详细

iOS---通过正则判断手机号码

时间:2016-04-12 11:11:05      阅读:171      评论: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];
    return [phoneTest evaluateWithObject:mobile];
}i

iOS---通过正则判断手机号码

标签:

原文地址:http://www.cnblogs.com/ChouDanDan/p/5381807.html

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