Sub LKJL()
SS = "x+1=3-x+2y"
Set reg = CreateObject("VBSCRIPT.REGEXP")
reg.Global = True
reg.Pattern = "[/+-/*///^=]"
Set mc = reg.Execute(SS)
bb = Split(reg.Replace(SS, "|"), "|")
For i = 0 To UBound(bb)
If Len(bb(i)) = 1 And Not IsNumeric(bb(i)) Then
aa = "1*" & bb(i)
Else
aa = bb(i)
End If
If i = UBound(bb) Then
cc = ""
Else
cc = mc.Item(i)
End If
kk = kk & aa & cc
Next
MsgBox kk
End Sub
我认为分两步。
一、x 替换成 1*x
二、*1*x 替换成 *x