Check out example codes for "swift string keep only 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