Replacing Elements in a String
One of the most common problems we face when working with strings is modifying certain characters in the string.
This problem can be easily solved with the use of regular expressions (regex).
Before Swift 5.7 If you can’t uae the newest Swift you can achieve this by using the method replacingOccurrences(of:with:options).
Here is an example of its use:
let s = "12abc34" let t = ss.replacingOccurrences( of: "[a-z]", // regex with: "", options: .