我有一张带有从服务器转储的URL的Excel工作表,我的任务是匹配某些模式并提取ID,我不是https://abcd.com/000001","Goods1
的专家但是有一个开始。
您能否请看下面的示例,让我知道如何最好地取出ID,提前致谢
( “
Function ExtractIds(urlstr As String) Dim reg Dim rng As Range, i As Long, j As Long Dim mtch, mt As String Set reg = CreateObject("vbscript.regexp") With reg .IgnoreCase = True .MultiLine = False .Pattern = "/(.*?)""" .Global = False End With MsgBox reg.Test(tmpStr) If reg.Test(tmpStr) Then ExtractIds = reg.Execute(tmpStr)(0).SubMatches(0) End If End Function
”)
我需要取出 000001
test_
答案 0 :(得分:2)
怎么样:
Public Function ExtractIds(urlstr As String)
ary = Split(urlstr, "*")
ExtractIds = ary(2)
End Function
修改#1:强>
根据您的编辑改为使用:
Public Function ExtractIds(urlstr As String)
Dim DQ As String
DQ = Chr(34)
ary = Split(urlstr, DQ)
bry = Split(ary(1), "/")
ExtractIds = bry(UBound(bry))
End Function