如何从电话号码中删除破折号、括号和空格?

时间:2020-12-27 18:34:10

标签: swift string

我有一个电话号码 String,格式如下:+1 (123) 456-7890,我希望将其更改为:1234567890。我该怎么做?我尝试了下面的代码,但它仍然显示相同的格式。

     let phone = phoneNumber.text?.replacingOccurrences(of: "[()\\s-]+", with: "", options: .literal, range: nil)
     print("phone Number \(phone)")

0 个答案:

没有答案
相关问题