do like
let NumberStr: String = "????-??-??"
let Formatter = NumberFormatter()
Formatter.locale = NSLocale(localeIdentifier: "EN") as Locale!
if let final = Formatter.number(from: NumberStr) {
print(final)
}
output
the alternate way
Option 2
extension String {
public var arToEnDigits : String {
let arabicNumbers = ["?": "0","?": "1","?": "2","?": "3","?": "4","?": "5","?": "6","?": "7","?": "8","?": "9"]
var txt = self
arabicNumbers.map { txt = txt.replacingOccurrences(of: $0, with: $1)}
return txt
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…