[英]VBS - Remove part of string after last “/”
This is what I have: 这就是我所拥有的:
Dim pathBefore
pathBefore = "product/subproduct/item/item"
This is what I need to get from pathBefore: 这是我需要从pathBefore获得的:
Dim pathAfter
pathAfter = "product/subproduct/item"
What I can do to achieve this? 我该怎么做才能做到这一点? I have tried with RegEx but it is not acceptable solution. 我已经尝试过RegEx,但这不是可接受的解决方案。
@Gurman: @Gurman:
>> s = "product/subproduct/item/item"
>> a = Split(s, "/")
>> ReDim Preserve a(UBound(a) - 1)
>> WScript.Echo Join(a, "/")
>> WScript.Echo goFS.GetParentFolderName(s)
>> WScript.Echo Left(s, InstrRev(s, "/") - 1)
>>
product/subproduct/item
product/subproduct/item
product/subproduct/item
找到最后一个/
然后读到这一点-1
pathAfter = left$(pathBefore, instrrev(pathBefore, "/") - 1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.