正则汇总 个人汇总 不断更新中
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];
}
+ (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];
}
相关文章推荐
- Oracle9i 问题汇总--不断更新中
- 个人常用eclipse快捷键,不断更新
- Windows CardSpace (formerly "InfoCard") 资料汇总(不断更新)
- Unix/Linux开源世界资源链接汇总【不断更新】
- 常用正则表达式【原创】【不断更新中】
- 常用的正则表达式(会不断更新)
- 个人知识图谱的建立步骤-算法工程师(不断更新)
- 个人收藏有用的Blog(不断更新)
- TOMCAT6.0 问题解决汇总(struts2相关) ——不断更新中
- 常用正则表达式汇总【个人收藏】
- C#常用知识汇总问与答(不断更新中...)
- 个人脚本收藏[不断更新 last update 2005-12-10]
- 【POJ各种模板汇总】(写在逆风省选前)(不断更新中)
- 【java】Maven项目开发中常用的依赖包汇总,不断更新
- 个人安全站点汇总(随时更新)
- Android常用知识点汇总(不断更新)
- VS2010 使用技巧汇总(不断更新中)
- B/S开发中个人典藏js函数 汇总帖(不断更中)
- eclipse快捷键汇总(不断更新添加)