remove \\u{e2} characters from string

前端 未结 3 2013
滥情空心
滥情空心 2021-01-15 21:25

I copied mobile number from contact . I got it like \"8008708600\\u{e2}\" . I wish to remove \\u{e2} from string. String is copied with exponent character

3条回答
  •  渐次进展
    2021-01-15 21:36

    I made a function for help:

    public func formatContactsPhoneNumber(number: String) -> String {
        var buffer = ""
        for (i, char) in number.unicodeScalars.enumerated() {
            guard CharacterSet.decimalDigits.contains(char) else {
                continue
            }
            buffer.append(number[i])
        }
        return buffer
    }
    

    It's work well for me.

提交回复
热议问题