'测试:将“abc@@eee”中的@@提取出来Sub test()MsgBox GetValueByRegex("abc@@eee", "abc(.*?)eee")End SubFunction GetValueByRegex(ByVal OrgStr As String, ByVal PatternStr As String)Set re = CreateObject("VBScript.RegExp")re.Pattern = PatternStrre.Global = Truere.IgnoreCase = FalseSet matchs = re.Execute(OrgStr)If matchs.Count > 0 ThenGetValueByRegex = matchs(0).submatches(0)ElseGetValueByRegex = ""End IfEnd Function
1200字范文,内容丰富有趣,写作的好帮手!