Skip to content

Instantly share code, notes, and snippets.

@masters3d
Created February 2, 2015 14:33
Show Gist options
  • Save masters3d/74ca6e214ce402507b7b to your computer and use it in GitHub Desktop.
Save masters3d/74ca6e214ce402507b7b to your computer and use it in GitHub Desktop.
String stripCharSet()
extension String {
func stripCharSet(charSet:NSCharacterSet) -> String{
let tempstring:NSArray = self.componentsSeparatedByCharactersInSet(charSet)
let returnString = tempstring.componentsJoinedByString("")
return returnString
}
var stripWhiteSpace:String { get {
return stripCharSet(.whitespaceAndNewlineCharacterSet())
}}
var stripPunctuations:String { get {
return stripCharSet(.punctuationCharacterSet())
}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment