I need to determine if a string contains any of the characters from a custom set that I have defined.
I see from this post that you can use rangeOfString to determine
Using Swift 3 to determine if your string contains characters from a specific CharacterSet:
let letters = CharacterSet.alphanumerics let string = "my-string_" if (string.trimmingCharacters(in: letters) != "") { print("Invalid characters in string.") } else { print("Only letters and numbers.") }