alihilal
alihilal
Reputation Top 5%
alihilal
1 Snippet  (433rd place)
Published
1 Channel
Created
2 Channels
Following
35 points  (824th place)
Reputation
Junior Code Generator
Junior Publisher
Junior Commenter
Junior Judge
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Junior Snip2Coder

Recent Snippets See all snippets by alihilal

public by alihilal  210  1  6  1

Remove all leading and trailing white spaces of string in Swift

handy Swift string extension that helps to remove all leading and trailing white spaces in a string https://www.alihilal.com/snippets?id=swift-remove-whitespace-string
import  Foundation
extension String {
     func  strip()  -> String{ 
         return   self.trimmingCharacters(in: CharacterSet.whitespaces)
        }
}
// White spaced string
var string = "    Hello, World   "
string.strip()
//Result -> "Hello, World"

																																				
;