DEV Community

Alberto Giambone 👨‍🌾
Alberto Giambone 👨‍🌾

Posted on

Replace String part on Swift

HI all,
some years ago i needed to substitute "," with "." in a String.

I used this func :
extension String {
mutating func replace(_ originalString:String, with newString:String) {
self = self.replacingOccurrences(of: originalString, with: newString)
}
}

but today I discovered Swift has a Method replacingOccurrences in a String 🥳🥳

Top comments (0)