Filter non-digits from string

后端 未结 12 1114
日久生厌
日久生厌 2020-12-01 11:36

Using only swift code I cant figure out how to take \"(555) 555-5555\" and return only the numeric values and get \"5555555555\". I need to remove all the parentheses, whit

12条回答
  •  遥遥无期
    2020-12-01 12:20

    Not exactly answered but it looks like a number. I used URLComponents to build the url because it strips out parenthesis and dashes automatically:

    var telUrl: URL? {
        var component = URLComponents()
        component.scheme = "tel"
        component.path = "+49 (123) 1234 - 56789"
        return component.url
    }
    

    then

    UIApplication.shared.open(telUrl, options: [:], completionHandler: nil)
    

    calls +49 123 123456789

提交回复
热议问题