iOS 手机号码和邮箱的验证
2016-06-24 14:27
573 查看
/*手机号码验证 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) isValidateMobile:(NSString *)mobile
{
//手机号以13,
15,18,14,17,开头,九个个 \d
数字字符
// /^1(3|4|5|7|8)\d{9}$/
NSString *phoneRegex =
@"^1(3|4|5|7|8)\\d{9}$";
NSPredicate *phoneTest = [NSPredicate
predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
// NSLog(@"phoneTest is %@",phoneTest);
return [phoneTest
evaluateWithObject:mobile];
}
/*邮箱验证 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];
}
+(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) isValidateMobile:(NSString *)mobile
{
//手机号以13,
15,18,14,17,开头,九个个 \d
数字字符
// /^1(3|4|5|7|8)\d{9}$/
NSString *phoneRegex =
@"^1(3|4|5|7|8)\\d{9}$";
NSPredicate *phoneTest = [NSPredicate
predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
// NSLog(@"phoneTest is %@",phoneTest);
return [phoneTest
evaluateWithObject:mobile];
}
/*邮箱验证 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];
}
相关文章推荐
- iOS 获取 顶层控制器
- iOS 编码和解码
- iOS开发者的99个绝佳资源
- ios 多个参数的block
- 6月24号XMG IOS 学习
- iOS关于数组的简单排序
- iOS关于系统原生通知的实现
- iOS开发NSDictionary字典介绍
- iOS数组NSArray介绍
- iOS内存管理(5)--深、浅拷贝与copy、strong
- iOS开发内存管理
- iOS ZipArchive
- iOS XCode7制作.Framework动态库和.a静态库的总结
- iOS开发之单元测试/Unit Tests
- iOS软件开发获取相机图片处理
- IOS多线程开发其实很简单
- iOS iTunes文件共享
- iOS开发-相关文档
- iOS Hybrid 框架 ——PhoneGap
- iOS_不常用方法总结