Remove special characters in search in a string iOS swift
Problem:
I'm having my string i want to remove the special characters in the string.How can i achieve that?
Solution:
func removeSpecialCharactersSearch() -> String {
let okayChars = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890 &/+,")
return String(self.unicodeScalars.filter { okayChars.contains($0) || $0.properties.isEmoji })
}
Comments
Post a Comment