I am trying to remove quotes from Swift String
something like:
"Hello"
so that the Swift String
is just:
Hello
You can simply use
Swift 1
var str: String = "\"Hello\""
print(str) // "Hello"
print(str.stringByReplacingOccurrencesOfString("\"", withString: "")) // Hello
Update for Swift 3 & 4
print(str.replacingOccurrences(of: "\"", with: "")) // Hello
"\"Hello\"".stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: "\""))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With