objective_c验证邮箱地址是否正确

-(BOOL) isEmailAddress:(NSString*)email {
    
    NSString *emailRegex = @"^\\w+((\\-\\w+)|(\\.\\w+))*@[A-Za-z0-9]+((\\.|\\-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$";
    
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    
    return [emailTest evaluateWithObject:email];
    
}

posted @ 2012-07-08 17:38  高笑228  阅读(465)  评论(0编辑  收藏  举报