您好,登錄后才能下訂單哦!
#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號(hào)碼
+ (BOOL) validateQQ:(NSString *)email
{
NSString *emailRegex = @"^\\\\d{5,12}$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
#pragma mark ***號(hào)
+ (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];
}
手機(jī)號(hào)碼的那個(gè)正則,網(wǎng)上的幾乎都不好用,都有bug,所以建議還還是判斷手機(jī)號(hào)11位,是不是1開頭的,我感覺就可以了,只能是數(shù)字
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。