邮箱格式判断(忘了从哪来看到的)

-(BOOL)isValidateEmail:(NSString *)email

{
    
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailRegex];
    
    return [emailTest evaluateWithObject:email];
    
}


6位数字验证码判断,依葫芦画瓢

-(BOOL)isValidCheckCode:(NSString *)checkCode
{
    NSString *checkCodeRegex = @"[0-9][0-9][0-9][0-9][0-9][0-9]";
    
    NSPredicate *chekCodeTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",checkCodeRegex];
    
    return [chekCodeTest evaluateWithObject:checkCode];
    
}


posted on 2014-07-08 14:30  超级庄子  阅读(139)  评论(0编辑  收藏  举报

导航