您的位置:首页 > 其它

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

2013-09-22 15:46 288 查看
/*手机号码验证 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];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: