tia_kamakshi
asked on
Substring in ASP
Hi,
I am working on ASP project
I have a string below
I wanted to remove all the text after the last string "\" and "\" this also get deleted.
For Example if string has text
1. \projects\AspImageProject\ ImageUploa d\Processe d\ASPImage Project\Im ageFilePat h
then after substring I should get the result string as
\projects\AspImageProject\ ImageUploa d\Processe d\ASPImage Project
2.
If String is
\projects\AspImageProject\ ImageUploa d\Processe d\ASPImage Project
then result substring should be
\projects\AspImageProject\ ImageUploa d\Processe d
Can anyone help me writting this in ASP
Many Thanks
I am working on ASP project
I have a string below
I wanted to remove all the text after the last string "\" and "\" this also get deleted.
For Example if string has text
1. \projects\AspImageProject\
then after substring I should get the result string as
\projects\AspImageProject\
2.
If String is
\projects\AspImageProject\
then result substring should be
\projects\AspImageProject\
Can anyone help me writting this in ASP
Many Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Thanks for your help.
I am getting hard to use it. I havn't work much on ASP. But I workes on ASP.net allot
I am using your code as below. And it is giving me blank value. Can you please help me in using this function
<a href='browseDir.asp?folder
<%
Function GetAbsolutePath(ByVal sURL)
Dim sPagePath
sPagePath = ""
If (Trim(sURL & "") <> "") Then
If InStrRev(sURL, "\") Then
sPagePath = Left(sURL, InStrRev(sURL, "\")-1)
End If
End If
GetAbsolutePath = sPagePath
End Function
%>
Many Thanks
ASKER
Many Thanks
You may want to add some checks but it boils down to this
s = "\projects\AspImageProject \ImageUplo ad\Process ed\ASPImag eProject\I mageFilePa th"
s = Left(s, InstrRev(s,"\")-1)
Response.Write s
Or using your function. Assuming it's ASP (Classic) forget about the byVal:
Response.Write GetAbsolutePath("\projects \AspImageP roject\Ima geUpload\P rocessed\A SPImagePro ject\Image FilePath")
Function GetAbsolutePath(sURL)
Dim sPagePath
sPagePath = ""
If (Trim(sURL & "") <> "") Then
If InStrRev(sURL, "\") > 0 Then
sPagePath = Left(sURL, InStrRev(sURL, "\")-1)
End If
End If
GetAbsolutePath = sPagePath
End Function
s = "\projects\AspImageProject
s = Left(s, InstrRev(s,"\")-1)
Response.Write s
Or using your function. Assuming it's ASP (Classic) forget about the byVal:
Response.Write GetAbsolutePath("\projects
Function GetAbsolutePath(sURL)
Dim sPagePath
sPagePath = ""
If (Trim(sURL & "") <> "") Then
If InStrRev(sURL, "\") > 0 Then
sPagePath = Left(sURL, InStrRev(sURL, "\")-1)
End If
End If
GetAbsolutePath = sPagePath
End Function
Open in new window