'测试:将“abc@@eee”中的@@提取出来
Sub test()
MsgBox GetValueByRegex("abc@@eee", "abc(.*?)eee")
End Sub
Function GetValueByRegex(ByVal OrgStr As String, ByVal PatternStr As String)
Set re = CreateObject("VBScript.RegExp")
re.Pattern = PatternStr
re.Global = True
re.IgnoreCase = False
Set matchs = re.Execute(OrgStr)
If matchs.Count > 0 Then
GetValueByRegex = matchs(0).submatches(0)
Else
GetValueByRegex = ""
End If
End Function