iOS Swift 4 Coding

How to replace characters in a string with Swift?

5 views August 31, 2018 August 31, 2018 bicobro 0

When you want to replace specific characters in a String. Use the replaceOccurrencies member of the String class.

let myString = "ABCDEFG"
let replacementResult = replacingOccurrences(of: "ABC", with: "123")
// replacementResult = "123DEFG"

 

Was this helpful?