Trim exacto de espacios

extension String { func trimExcessiveSpaces() -> String { let components = self.componentsSeparatedByCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) let filtered = components.filter({!$0.isEmpty}) return filtered.joinWithSeparator(" ") } }
Antes:" hola como motherfucker estas funcionan "

Despues: "hola como motherfucker estas funcionan"

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.