我从联系中复制了手机号码。我得到它像“8008708600 \ u {e2}”。我希望从字符串中删除 \ u {e2} 。使用我不想要的指数字符复制字符串。
例如:“8008708600 \ u {e2}” 所以期望的输出 8008708600
我使用了以下代码
let formattedString = string.replacingOccurrences(of: " \\u{e2}”, with: "")
非常感谢任何帮助,非常感谢!
答案 0 :(得分:1)
我做了一个帮助功能:
Sub test()
clr = vbYellow
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
With ws
lastrow = .Cells(.Rows.Count, 14).End(xlUp).Row
For i = 1 To lastrow - 1
For j = i + 1 To lastrow
If .Cells(i, 14).Value = -1 * .Cells(j, 14).Value And .Cells(i, 14).Interior.Color <> clr And .Cells(j, 14).Interior.Color <> clr Then
.Cells(i, 14).Interior.Color = clr
.Cells(j, 14).Interior.Color = clr
Exit For 'include this if the list is long to speed things up
End If
Next
Next
End With
End Sub
对我来说很好。
答案 1 :(得分:0)
我使用了以下代码:
var str = "8008708600\u{e2}"
str = str.replacingOccurrences(of: "\u{e2}", with: "")
print(str)
输出:
希望这有帮助。
答案 2 :(得分:0)
代码:
var number = self.yourTextField.text
self.yourTextField.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.yourTextField.text = number!