Until Swift 2 I used this extension to remove multiple whitespaces:
func condenseWhitespace() -> String { let components = self.componentsSeparatedByC
var str = "Hello World.\nHello!" if let regex = try? NSRegularExpression(pattern: "\\s+", options:NSRegularExpression.Options.caseInsensitive) { str = regex.stringByReplacingMatches(in: str, options: [], range: NSMakeRange(0, str.count), withTemplate: " ") }