Strings In Depth11 / 18
Up next

Replace text

import Foundation

let s = "one two two three"
// returns a new String with every match replaced
let fixed = s.replacingOccurrences(of: "two", with: "2")
print(fixed)
What you're solving

replacingOccurrences(of:with:)