Check out example codes for "replace character in swift". It will help you in understanding the concepts better.

Code Example 1

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

Learn ReactJs, React Native from akashmittal.com