'替换
Function YF_Replace(Expression As String, Find As String, Replacewith As String) As String
   Dim As  Long  FF(),ff1,i,u,Lf,Le,Lr,Lu,t
   Dim outstr As String
   Dim As UByte Ptr pE,pF
   Dim As Any Ptr pU,pR
   Le = Len(Expression)
   Lf = Len(Find)
   Lr = Len(Replacewith)
   If Le = 0 Or Lf = 0 Then
      Return Expression
   Else
      '先找出替换数与位置----------------------------------
      u = -1
      ReDim ff(100)
      pE = StrPtr(Expression)
      pR = StrPtr(Replacewith)
      pF = StrPtr(Find)
      For i = 0 To Le - Lf
         If pe[i] = pf[0] Then
            If MemCmp(@pe[i], pf, lf) = 0 Then
               u += 1
               If u > UBound(ff) Then ReDim Preserve ff(u + 100)
               ff(u) = i
               i += lf -1
            End If
         End If
      Next
      If u = -1 Then
         Return Expression
      Else
         Lu = Le + (Lr - Lf) * (u + 1)  'Lu=Le - Lf * (u+1) + Lr * (u+1)
         outstr = String(Lu, 0)
         pU = StrPtr(outstr)
         t = 0
         For i = 0 To u
            Lu = FF(i) - t
            If Lu > 0 Then '复制原字符
               MemCpy(pU, pE, Lu)
               pU += Lu
            End If
            If Lr > 0 Then '复制替换字符
               MemCpy(pU, pR, Lr)
               pU += Lr
            End If
            pE += Lu + Lf
            t += Lu + Lf
         Next
         If t < le Then
            lu = le - t
            MemCpy(pU, pE, Lu)
         End If
         Return outstr
      End If
   End If
   
   
End Function
