Check out example codes for "swift replace all characters except numbers". It will help you in understanding the concepts better.
Code Example 1
let result = string.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789.").inverted)
Learn ReactJs, React Native from akashmittal.com