Created
February 2, 2015 14:33
-
-
Save masters3d/74ca6e214ce402507b7b to your computer and use it in GitHub Desktop.
String stripCharSet()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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