/*
匹配电话号码
*/
-( BOOL )matchPhone:( NSString *)str
{
if ([str isEqualToString : @" 联系电话 " ]) {
return YES ;
} else
{
// 座机
NSString *phoneRegex1 = @"\\d{3}-\\d{8}|\\d{4}-\\d{7,8}" ;
NSPredicate *phoneTest1 = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , phoneRegex1];
// 手机
NSString *phoneRegex2 = @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0,5-9])|(17[0,5-9]))\\d{8}$" ;
NSPredicate *phoneTest2 = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , phoneRegex2];
return ([phoneTest1 evaluateWithObject :str]||[phoneTest2 evaluateWithObject :str]);
}
}
/* 匹配 QQ*/
-( BOOL )matchQQ:( NSString *)str
{
if ([str isEqualToString : @"QQ 号 " ]) {
return YES ;
} else
{
NSString *emailRegex = @"[0-9]{5,12}" ;
NSPredicate *emailTest = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , emailRegex];
return [emailTest evaluateWithObject :str];
}
}
/* 匹配邮箱 */
-( BOOL )matchMail:( NSString *)str
{
if ([str isEqualToString : @" 邮箱 " ]) {
return YES ;
} else
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z].*" ;
NSPredicate *emailTest = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , emailRegex];
return [emailTest evaluateWithObject :str];
}
}
-( BOOL )matchPhone:( NSString *)str
{
if ([str isEqualToString : @" 联系电话 " ]) {
return YES ;
} else
{
// 座机
NSString *phoneRegex1 = @"\\d{3}-\\d{8}|\\d{4}-\\d{7,8}" ;
NSPredicate *phoneTest1 = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , phoneRegex1];
// 手机
NSString *phoneRegex2 = @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0,5-9])|(17[0,5-9]))\\d{8}$" ;
NSPredicate *phoneTest2 = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , phoneRegex2];
return ([phoneTest1 evaluateWithObject :str]||[phoneTest2 evaluateWithObject :str]);
}
}
/* 匹配 QQ*/
-( BOOL )matchQQ:( NSString *)str
{
if ([str isEqualToString : @"QQ 号 " ]) {
return YES ;
} else
{
NSString *emailRegex = @"[0-9]{5,12}" ;
NSPredicate *emailTest = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , emailRegex];
return [emailTest evaluateWithObject :str];
}
}
/* 匹配邮箱 */
-( BOOL )matchMail:( NSString *)str
{
if ([str isEqualToString : @" 邮箱 " ]) {
return YES ;
} else
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z].*" ;
NSPredicate *emailTest = [ NSPredicate predicateWithFormat : @"SELF MATCHES %@" , emailRegex];
return [emailTest evaluateWithObject :str];
}
}