当我从电话应用程序复制电话号码时,我会得到类似\u{e2}05xxxxxx49\u{e2}
的结果
我需要从数字的左侧和右侧删除此字符\u{e2}
得到这样的结果05xxxxxx49
var str = number
str = str!.replacingOccurrences(of: "\u{e2}", with: "")
print(str!)
答案 0 :(得分:0)
感谢所有人 终于我知道了
var number = self.myTFForNumber.text
self.myTFForNumber.text = ""
let onlyDigits: CharacterSet = CharacterSet.decimalDigits.inverted
let greeting = number!
number = ""
for aa in 0..<greeting.count
{
let index = greeting.index(greeting.startIndex, offsetBy: aa)
let bb = String(describing: greeting[index])
if bb.rangeOfCharacter(from: onlyDigits) == nil {
number = "\(String(describing: number!))\(greeting[index])"
}
}
self.myTFForNumber.text = number!