I\'ve got a problem with removing whitespaces at the beginning and end of string. For e.g. I\'ve got a string like:
\\r\\n\\t- Someone will come here?\\n- I d
In Swift 4 Use it on any String type variable.
extension String { func trimWhiteSpaces() -> String { let whiteSpaceSet = NSCharacterSet.whitespaces return self.trimmingCharacters(in: whiteSpaceSet) } }
And Call it like this
yourString.trimWhiteSpaces()