iOS判断邮箱,手机号码,车牌号是否合法的正则表达
2018-07-20 来源:open-open
/*邮箱验证 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]; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇: rmq算法
下一篇:PHP获取时间段代码
最新资讯
热门推荐