DEV Community

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)