string VBScript 有 substring() 函数吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2223287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does VBScript have a substring() function?
提问by Carlos Blanco
Is there a substring()
function in VBScript similar to Java's string.substring()
?
substring()
VBScript 中是否有类似于 Java 的函数string.substring()
?
回答by Tmdean
Yes, Mid
.
是的,Mid
。
Dim sub_str
sub_str = Mid(source_str, 10, 5)
The first parameter is the source string, the second is the start index, and the third is the length.
第一个参数是源字符串,第二个是起始索引,第三个是长度。
@bobobobo: Note that VBScript strings are 1-based, not 0-based. Passing 0 as an argument to Mid
results in "invalid procedure call or argument Mid".
@bobobobo:请注意,VBScript 字符串是基于 1 的,而不是基于 0 的。将 0 作为参数传递会Mid
导致“无效的过程调用或参数 Mid”。
回答by Kev
As Tmdean correctly pointed outyou can use the Mid()
function. The MSDN Library also has a great reference section on VBScript which you can find here:
正如Tmdean 正确指出的那样,您可以使用该Mid()
功能。MSDN 库也有一个关于 VBScript 的很好的参考部分,你可以在这里找到: