如何在vbscript中子文化字符串

时间:2010-11-09 13:27:19

标签: vbscript

我正在使用VBScript

我有以下文字

str = "tcm:1-245-9"

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

来自上述字符串的

pstr = "245"

请告诉我VBScript中的建议。

感谢。

2 个答案:

答案 0 :(得分:14)

您可以使用

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

或使用

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

答案 1 :(得分:6)

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

segments = Split(str,"-")
pstr = segments(1)