how to replace all number value in a string by is string value swift 5 code example

Example 1: how to replace certain characters in string swift

let aString = "This is my string"
let newString = aString.replacingOccurrences(of: " ", with: "+", options: .literal, range: nil)

Example 2: replace character in swift

extension String {
	func withReplacedCharacters(_ oldChar: String, by newChar: String) -> String {
	    let newStr = self.replacingOccurrences(of: oldChar, with: newChar, options: .literal, range: nil)
	    return newStr
	}
}