|
爱疯 发表于 2012-2-19 17:56
现在,11#方法暂时领先
Function zh(s, sfind, sreplace)
Dim t As String, icount As Long
If Len(s) < 3 Then zh = Replace(s, sfind, ""): Exit Function
t = String(Len(s), " ")
icount = 1
If Left(s, 1) <> sreplace Then
Mid(t, icount, 1) = Left(s, 1)
icount = icount + 1
End If
For i = 2 To Len(s)
If Mid(s, i, 1) = sfind Then
If Mid(s, i - 1, 1) <> sfind Then
Mid(t, icount, 1) = sreplace
icount = icount + 1
End If
Else
Mid(t, icount, 1) = Mid(s, i, 1)
icount = icount + 1
End If
Next
If Mid(t, icount - 1, 1) = "," Then
zh = Left(t, icount - 2)
Else
zh = Left(t, icount - 1)
End If
End Function
|
|