您好,登錄后才能下訂單哦!
#pragma mark 判斷郵箱的
+(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];
}
#pragma mark QQ號碼
+ (BOOL) validateQQ:(NSString *)email
{
NSString *emailRegex = @"^\\\\d{5,12}$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
#pragma mark ***號
+ (BOOL) validateIdentityCard: (NSString *)identityCard
{
BOOL flag;
if (identityCard.length <= 0) {
flag = NO;
return flag;
}
NSString *regex2 = @"^(\\\\d{14}|\\\\d{17})(\\\\d|[xX])$";
NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
return [identityCardPredicate evaluateWithObject:identityCard];
}
#pragma mark 判斷昵稱的
+ (BOOL) validateNickname:(NSString *)nickname
{
NSString *phoneRegex = @"[\\u4e00-\\u9fa5]{2,7}";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
return [phoneTest evaluateWithObject:nickname];
}
手機號碼的那個正則,網上的幾乎都不好用,都有bug,所以建議還還是判斷手機號11位,是不是1開頭的,我感覺就可以了,只能是數字
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。