我编写了少量代码来将 url 修剪到最后一个路径,直到到达主机,但它不能正常工作:
Dim line As String
line = "http://www.domain.com/folder1/folder2/folder3/folder4/"
line = Replace(line, "http://", "")
Dim count As Integer
count = line.Split("/").Length - 1
For x = count To 1 Step -1
count = line.Split("/").Length - 1
Dim lastpath As String = line.Split("/")(x).Split("/")(0)
Dim newline As String = Replace(line, "/" & lastpath, "")
MsgBox(newline)
在我的情况下,我希望看到 5 个带有 url 且没有最后路径的框消息:
www.domain.com/folder1/folder2/folder3/folder4
www.domain.com/folder1/folder2/folder3
www.domain.com/folder1/folder2
www.domain.com/folder1
www.domain.com