iOS 判断邮箱,手机的方法

/*邮箱验证 MODIFIED BY HELENSONG*/
-(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];
}

/*手机号码验证 MODIFIED BY HELENSONG*/
-(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];
//    NSLog(@"phoneTest is %@",phoneTest);
    return [phoneTest evaluateWithObject:mobile];
}

/*车牌号验证 MODIFIED BY HELENSONG*/
BOOL validateCarNo(NSString* carNo)
{
    NSString *carRegex = @"^[A-Za-z]{1}[A-Za-z_0-9]{5}$";
    NSPredicate *carTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",carRegex];
    NSLog(@"carTest is %@",carTest);
    return [carTest evaluateWithObject:carNo];
}
时间: 2024-10-29 10:46:22

iOS 判断邮箱,手机的方法的相关文章

ios 判断邮箱是否正确

ios 判断邮箱是否正确     - (BOOL)isValidateEmail:(NSString *)Email { NSString *emailCheck = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailCh

iOS 判断iPhone机型的方法

+ (BOOL)isNotIphone3G { static BOOL done = FALSE; static BOOL result; if (!done) { size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = malloc(size); sysctlbyname("hw.machine", machine, &size, NULL, 0)

iOS 判断电话号 几种方法

- (BOOL)isMobileNumber:(NSString *)mobileNum { /** * 手机号码 * 移动:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188 * 联通:130,131,132,152,155,156,185,186 * 电信:133,1349,153,180,189 */ //    NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d

iOS 判断邮箱格式是否正确的代码

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

iOS判断UIScrollView的滚动方法

- (void) scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat newY = scrollView.contentOffset.y; if (newY != _oldY) { if (newY > _oldY && (newY - _oldY) > 100) { NSLog(@"Down"); _oldY = newY; } else if (newY < _oldY &&am

判断邮箱,手机,QQ的格式

#pragma mark 判断邮箱,手机,QQ的格式 -(BOOL)isValidateEmail:(NSString *)email{ NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@"

iOS开发——判断邮箱格式

//判断邮箱格式 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailRegex]; ret

IOS 判断应用版本和升级提示

原文地址:http://blog.csdn.net/jslsblog/article/details/9932767 ios中应用的版本判断有两种方法: 1.将你的应用版本号同步在你自己的服务器上,打开程序后去自己的服务器获取版本号和手机上的应用版本号做比较,然后去appstore升级 2.通过url获取appstore上的最新版本信息,然后和手机上的程序版本号做比较,判断是否升级. 最常用的就是方法2,下面讲讲方法2的实现过程. 第一步是去获取appstore上你的应用的版本信息,需要用到的u

iOS 判断是push还是present

iOS 判断是push还是present下面这种方法判断成功了  if (self.presentingViewController)   {      [weakSelf dismissViewControllerAnimated:YES completion:nil];    }    else {       [weakSelf.navigationController popViewControllerAnimated:YES];      }