Created
March 19, 2018 15:51
-
-
Save cafielo/eb4fd5f9762d4cf0cc938f77b6f799c7 to your computer and use it in GitHub Desktop.
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 trimTrailingWhitespaces() -> String { | |
return self.replacingOccurrences(of: "\\s+$", with: "", options: .regularExpression) | |
} | |
} | |
let string = "there is string with trailing whitespace " | |
let trimmed = string.trimTrailingWhitespaces() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment