带有 2 个撇号的字符串 - 从字符串中删除其中一个撇号



所以我有一个小问题....

我有一个看起来像这样的字符串...

O''Neil

有没有办法让我删除其中一个撇号?基本上我想把它转换回

O'Neil

希望这可以帮助您:注意- 我把错误处理留给了你。

Imports System
Public Module Module1
Public Sub Main()
Dim data As String = "O''Neil"
Dim in1 As Integer = data.IndexOf("'"C) ' get the index of first quote
Dim in2 As Integer = data.IndexOf("'"C, in1 + 1)  ' get the index of second     
Dim result As String = data.Remove(in2, 1)  ' remove the second quote
Console.WriteLine(result)
End Sub
End Module

最新更新