毕业论文
您现在的位置: 电子信箱 >> 电子信箱市场 >> 正文 >> 正文

手机号码电子邮箱车牌号格式验证

来源:电子信箱 时间:2022/5/6
北京中科白癜风医院平安医院 http://www.zherpaint.com/

//验证邮箱格式是否正确

-(BOOL)validateEmail:(NSString*)candidate

{

NSString*emailRegex=

[A-Z0-9a-z._%+-]+

[A-Za-z0-9.-]+\\.[A-Za-z]{2,4};

NSPredicate*emailTest=[NSPredicatepredicateWithFormat:

SELFMATCHES%

,emailRegex];

return[emailTestevaluateWithObject:candidate];

}

//验证车牌号格式

-(BOOL)validateCarNo:(NSString*)carNo{

NSString*carRegex=

^[A-Za-z]{1}[A-Za-z_0-9]{5};

NSPredicate*carTest=[NSPredicatepredicateWithFormat:

SELFMATCHES%

,carRegex];

NSLog(

carTestis%

,carTest);

return[carTestevaluateWithObject:carNo];

}

//验证手机号码格式

-(BOOL)isMobileNumber:(NSString*)mobileNum

{

NSString*MOBILE=

^1(3[0-9]

5[0-35-9]

8[-9])\\d{8};

NSString*CM=

^1(34[0-8]

(3[5-9]

5[-9]

8[])\\d)\\d{7};

NSString*CU=

^1(3[0-2]

5[]

8[56])\\d{8};

NSString*CT=

^1((33

53

8[09])[0-9]

)\\d{7};

//NSString*PHS=

^0(10

2[0-]

\\d{3})\\d{7,8};

NSPredicate*regextestmobile=[NSPredicatepredicateWithFormat:

SELFMATCHES%

,MOBILE];

NSPredicate*regextestcm=[NSPredicatepredicateWithFormat:

SELFMATCHES%

,CM];

NSPredicate*regextestcu=[NSPredicatepredicateWithFormat:

SELFMATCHES%

,CU];

NSPredicate*regextestct=[NSPredicatepredicateWithFormat:

SELFMATCHES%

,CT];

if(([regextestmobileevaluateWithObject:mobileNum]==YES)

([regextestcmevaluateWithObject:mobileNum]==YES)

([regextestctevaluateWithObject:mobileNum]==YES)

([regextestcuevaluateWithObject:mobileNum]==YES))

{

returnYES;

}

else

{

returnNO;

}

}

预览时标签不可点收录于话题#个上一篇下一篇 转载请注明:http://www.0431gb208.com/sjszlff/160.html

  • 上一篇文章:
  • 下一篇文章: 没有了