0

I have a phone number String that is formatted like this: +1 (123) 456-7890 and I want it to be changed to: 1234567890. How would I do that? I tried the code below but it still shows the same format.

     let phone = phoneNumber.text?.replacingOccurrences(of: "[()\\s-]+", with: "", options: .literal, range: nil)
     print("phone Number \(phone)")
pawello2222
  • 46,897
  • 22
  • 145
  • 209
xcode22
  • 118
  • 1
  • 9

0 Answers0