importFoundation
enum
ValIDate{
case
email(_:String)
case
phoneNum(_:String)
case
carNum(_:String)
case
username(_:String)
@H_301_45@
case
password(_:String)
case
nickname(_:String)
case
URL(_:String)
case
IP(_:String)
varisRight:Bool{
varpredicateStr:String!
varcurrObject:String!
switch
self{
case
let.email(str):
predicateStr=
"^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$"
currObject=str
case
let.phoneNum(str):
predicateStr=
"^((13[0-9])|(15[^4,\D])|(17[0,0-9])|(18[0,0-9]))\d{8}$"
currObject=str
case
let.carNum(str):
predicateStr=
"^[A-Za-z]{1}[A-Za-z_0-9]{5}$"
currObject=str
case
let.username(str):
predicateStr=
"^[A-Za-z0-9]{6,20}+$"
currObject=str
case
let.password(str):
predicateStr=
"^[a-zA-Z0-9]{6,20}+$"
currObject=str
case
let.nickname(str):
predicateStr=
"^[\u4e00-\u9fa5]{4,8}$"
currObject=str
case
let.URL(str):
predicateStr=
"^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?$"
currObject=str
case
let.IP(str):
predicateStr=
"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
currObject=str
}
letpredicate=nspredicate(format:
"SELFMATCHES%@"
,predicateStr)
return
predicate.evaluateWithObject(currObject)
}
}
总结 以上是内存溢出为你收集整理的Swift:邮箱网址手机号码等正则判断全部内容,希望文章能够帮你解决Swift:邮箱网址手机号码等正则判断所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)