I have a one String in classic asp.
Dim str
str = "http://stackoverflow.com/questions/ask/code-classic-asp-in-linux"
In above string, I want text after "code" by using split() in Classic asp.
Result should be: "-classic-asp-in-linux"
Neil is right. But in VBScript IndexOf
equivalent is InStr
.
Dim str
str = "http://stackoverflow.com/questions/ask/code-classic-asp-in-linux"
'Split
Response.Write Split(str,"-", 2)(1) ' classic-asp-in-linux
'Mid & InStr
Response.Write Mid(str, InStr(str, "-")) ' -classic-asp-in-linux
This is a really old post, I know, but maybe somebody will find this useful... I perceive the OP's actual question to be "how do I get the doc name from the end of a URL?" The answer is to get everything after the last slash. Here I use InStrRev to find the last slash, store it's position and then use the Right function to capture the end of the url.
Dim str, tmp
str = "http://stackoverflow.com/questions/ask/code-classic-asp-in-linux"
tmp = InStrRev(str, "/")
str = Right(str, Len(str) - tmp)
Response.write str
If the URL has a trailing slash on it, that would cause a problem, so in usage, you'd want to check for that possibility.
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