#pragma mark --判断手机号合法性

+ (BOOL)checkPhone:(NSString *)phoneNumber

{

    NSString *regex = @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$";

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

    BOOL isMatch = [pred evaluateWithObject:phoneNumber];

    if (!isMatch)

    {

        return NO;

    }

    return YES;

    

}

 

 

#pragma mark 判断邮箱

+ (BOOL)checkEmail:(NSString *)email{

    //^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$

    NSString *regex = @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";

    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

    return [emailTest evaluateWithObject:email];

}

相关文章:

  • 2021-11-21
  • 2022-01-02
  • 2021-11-21
  • 2022-01-04
  • 2022-02-07
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案