Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

split() in Classic asp

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"

like image 483
Jagadeesh Avatar asked Dec 02 '22 00:12

Jagadeesh


2 Answers

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
like image 164
Kul-Tigin Avatar answered Dec 20 '22 04:12

Kul-Tigin


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.

like image 22
Jon Jaques Avatar answered Dec 20 '22 05:12

Jon Jaques