如何在vbscript中子文化字符串

Man*_*ngh 4 vbscript

我正在使用VBScript

我有下面的文字

str = "tcm:1-245-9"
Run Code Online (Sandbox Code Playgroud)

现在我想以这种方式将字符串子串在字符串上,以便我得到如下的输出

pstr = "245" 从上面的字符串,

请让我知道VBScript中的建议.

谢谢.

Kan*_*kan 15

您可以使用

Mid(string,start[,length]) 

string - Required. The string expression from which characters are returned

start  - Required. Specifies the starting position. If set to greater than the number of characters in string, it returns an empty string ("")

length  - Optional. The number of characters to return
Run Code Online (Sandbox Code Playgroud)

或使用

Split(expression[,delimiter[,count[,compare]]]) 

expression - Required. A string expression that contains substrings and delimiters

delimiter  - Optional. A string character used to identify substring limits. Default is the space character

count      - Optional. The number of substrings to be returned. -1 indicates that all substrings are returned

compare    - Optional. Specifies the string comparison to use.

            Can have one of the following values:
              * 0 = vbBinaryCompare - Perform a binary comparison
              * 1 = vbTextCompare - Perform a textual comparison
Run Code Online (Sandbox Code Playgroud)


Mar*_*ell 6

如果字符串格式总是这样:

segments = Split(str,"-")
pstr = segments(1)
Run Code Online (Sandbox Code Playgroud)