判断手机号,密码的正则表达式

//判断密码6-16位
+ (BOOL)validatePassword:(NSString *)password{
    
    NSString *Regex = @"^[a-zA-Z0-9]{5,16}$";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
    
    return [emailTest evaluateWithObject:password];
}

//判断手机号11位
+ (BOOL)validateMobile:(NSString *)mobileNum{
    
    NSString *MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",MOBILE];
    
    return [regextestmobile evaluateWithObject:mobileNum];
}

 

posted @ 2014-06-25 11:20  2014_4_30  阅读(297)  评论(0编辑  收藏  举报