我创建了一个简单的函数,旨在从另一个字符串中删除一个字符串并将其替换为用户想要的任何字符串(或默认没有字符串)
Private Function RemoveString(scontainer As String, Optional rcontainer As String = "", Optional rstring As String = "") As String
Dim container As String = scontainer
Dim tcontainer As String
If InStr(container, rcontainer) <> 0 Then
Do While (InStr(container, rcontainer) <> 0)
tcontainer = Microsoft.VisualBasic.Left(container, InStr(container, rcontainer) - 1)
tcontainer = tcontainer & rstring & Microsoft.VisualBasic.Right(container, (Len(container) - (InStr(container, rcontainer) + 2)))
container = tcontainer
Loop
RemoveString = container 'return modded string
Else
RemoveString = scontainer 'return string as is
End If
End Function
问题是:虽然这应该是一个通用功能,但我真的需要它来关注 2 个不同的字符串
%20 安培;
该功能非常适合 %20 的情况,但它为 amp 留下了分号;细绳。任何想法为什么会这样?