alihilal
alihilal
Reputation Top 5%
alihilal
1 Snippet
Published
1 Channel
Created
2 Channels
Following
35 points
Reputation
Junior Code Generator
Junior Publisher
Junior Commenter
Junior Judge
Junior Autobiographer
Serious Autobiographer
Junior Snip2Coder

Recent Snippets See all snippets by alihilal

public by  78  1  4  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"

																																				
;