lundi 2 mars 2015

How to strip special characters out of string?

I have a set with the characters I allow in my string:


var characterSet:NSCharacterSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ")


I want to strip any other characters from a string so two unformatted data can be considered equal, like this:


"American Samoa".lowercaseString == "american_samoa1".lowercaseString


the lowercase version of these transformed strings would be "americansamoa"


Aucun commentaire:

Enregistrer un commentaire