Overloads Public Function Replace( _ ByVal oldValue As String, _ ByVal newValue As String _ ) As String
要看你的需求。例如“0040500”,是要变成“405”还是“45”。如果是后者,用上面的代码就行。 否则:'引用 Microsoft VBScript Regular Expressions 1.0 (或以上版本)Dim s As VBScript_RegExp_10Set s = New VBScript_RegExp_10.RegExp s.Pattern = "(\b0+)|(0+\b)" s.Global = True MsgBox s.Replace("00040500", "")
replace("004500","0",space(0))
ByVal oldValue As String, _
ByVal newValue As String _
) As String
否则:'引用 Microsoft VBScript Regular Expressions 1.0 (或以上版本)Dim s As VBScript_RegExp_10Set s = New VBScript_RegExp_10.RegExp
s.Pattern = "(\b0+)|(0+\b)"
s.Global = True
MsgBox s.Replace("00040500", "")