| Option Explicit | | | | Test | | | | | | Sub Test() | | | | | | Dim str, strPattern | | str = "https://agc.qq.com/show/chan" | | strPattern = "http[s]{0,1}:\/\/[0-9A-z\.]+?\/([^\/]+)?[\/]{0,1}?.*" | | MsgBox GetRE_SM0(str, strPattern) | | | | End Sub | | | | | | | | | | Function GetRE_SM0(ByVal str, ByVal strPattern) | | Dim oRE | | Set oRE = CreateObject("vbScript.regExp") | | oRE.Pattern = strPattern | | If oRE.Test(str) Then | | If oRE.Execute(str)(0).SubMatches.Count >= 1 Then | | GetRE_SM0 = oRE.Execute(str)(0).SubMatches(0) | | End If | | End If | | Set oRE = Nothing | | End FunctionCOPY |
|