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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift