khstar
Swift 닉네임 정규표현식 본문
반응형
var str:String = "김ㄱㅋ11!"
var str1:String? = nil
//str1 = " "
var a = str1 ?? "1"
print("a = \(a)")
//str.vali
extension String {
func validateNickname() -> Bool {
let emailRegEx = "^[ㄱ-ㅎ가-힣a-zA-Z0-9]{2,20}$"
let predicate = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return predicate.evaluate(with: self)
}
}
반응형
Comments