I am using VBScript
I have got below text
str = "tcm:1-245-9"
Now I want to substring above string in such a way, so that I get the output as below
pstr = "245"
from the above string,
Please let me know suggestions in VBScript only.
Thanks.
You can use
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
or use
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
If the string format will always be like that:
segments = Split(str,"-")
pstr = segments(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With