`
473687880
  • 浏览: 482558 次
文章分类
社区版块
存档分类
最新评论

正则汇总 个人汇总 不断更新中

 
阅读更多

/*手机号码验证 MODIFIED BY HELENSONG*/
+ (BOOL) isValidateMobile:(NSString *)mobile
{
//手机号以13, 15,18开头,八个 \d 数字字符
NSString *phoneRegex = @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0-9]))\\d{8}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
// //NSLog(@"phoneTest is %@",phoneTest);
return [phoneTest evaluateWithObject:mobile];
}


//匹配Email地址的正则表达式:^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$
//
+ (BOOL)isRightEmail:(NSString *)str
{
NSString *phoneRegex = @"^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
// //NSLog(@"phoneTest is %@",phoneTest);
return [phoneTest evaluateWithObject:str];
}

//17位 最后4位必须是数字
- (BOOL)isRightCarUniqueNumber:(NSString *)str
{
NSString *phoneRegex = @"^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
// //NSLog(@"phoneTest is %@",phoneTest);
return [phoneTest evaluateWithObject:str];
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics