是否是正確的郵箱格式
+ (BOOL)isValidateEmail:(NSString *)email
{
NSString *regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
return [predicate evaluateWithObject:email];
}
是否是正確的手機(jī)號碼格式
+ (BOOL)isValidateMobile:(NSString *)mobile
{
NSString *regex = @"^((13[0-9])|(14[5,7])|(15[^4,\\D])|(18[0,0-9])|(17[0,5-8]))\\d{8}$";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [predicate evaluateWithObject:mobile];
}
正則匹配用戶密碼6-18位數(shù)字和字母組合
+ (BOOL)checkPassword:(NSString *) password
{
// 正則匹配用戶密碼6-18位數(shù)字和字母組合
NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{6,18}";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
BOOL isMatch = [pred evaluateWithObject:password];
return isMatch;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者