How can all special characters be removed from a string without also removing emojis?
I've tried:
func removeSpecialCharsFromString(text: String) -> String {
let okayChars : Set<Character> =
Set("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890-& ".characters)
return String(text.characters.filter {okayChars.contains($0) })
}
– but this function also removes the emoji from the string.
Expected Result:
"Hello guys !? Need some money $ "
Actual Result:
"Hello guys Need some money "