func hasCharacters() -> Bool {
let pattern = "^[0-9a-zA-Z가-힣ㄱ-ㅎㅏ-ㅣ`~!@#$%^&*()\\-_=+\\[{\\]}\\\\|;:'\",<.>/?\\s]{0,}$"
let regex = try? NSRegularExpression(pattern: pattern , options: .caseInsensitive)
if let _ = regex?.firstMatch(in: self, options: [], range: NSRange(location: 0, length: self.count)) {
return true
}
return false
}
자료 출처: 정규식으로 유효성 확인