如何在swift中删除电话号码中的特殊字符?

如何在swift中删除电话号码中的特殊字符?,swift,numbers,format,Swift,Numbers,Format,当我从手机应用程序复制号码电话时,我得到如下结果\u{e2}05xxxxxx49\u{e2} 我需要从数字的左右两侧删除这个字符\u{e2} 要得到这样的结果05xxxxxx49 var str = number str = str!.replacingOccurrences(of: "\u{e2}", with: "") print(str!) 谢谢大家 我终于知道了 可能与您重复,使其过于复杂字符串(number.unicodeCharacters.filter{CharacterSet.

当我从手机应用程序复制号码电话时,我得到如下结果
\u{e2}05xxxxxx49\u{e2}

我需要从数字的左右两侧删除这个字符
\u{e2}
要得到这样的结果
05xxxxxx49

var str = number
str = str!.replacingOccurrences(of: "\u{e2}", with: "")
print(str!)
谢谢大家 我终于知道了
可能与您重复,使其过于复杂<代码>字符串(number.unicodeCharacters.filter{CharacterSet.decimalDigits.contains($0)}),或
number.replacingOccurrences(of:[^0-9]”,with:,options:.regularExpression)
也会这样做。