Skip to content

Instantly share code, notes, and snippets.

@akramhussein
Last active August 29, 2015 14:18
Show Gist options
  • Save akramhussein/f008d9e572ca8d3312e6 to your computer and use it in GitHub Desktop.
Save akramhussein/f008d9e572ca8d3312e6 to your computer and use it in GitHub Desktop.
String+RemoveWords Extension
extension String
{
func removeWords(words: [String]) -> String
{
var cleanedString = self
// Remove common words
for word in words
{
cleanedString = cleanedString.stringByReplacingOccurrencesOfString(word, withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil)
}
// strip newlines and spaces
cleanedString = cleanedString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
return cleanedString
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment