Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 1st, 2005, 05:06 PM
Authorized User
Join Date: Oct 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default how do I strip a URL down to the filename?

How do I strip the URL down to just the file name?

I have
dim dept1, filename
dept1 = Session("Dept")
filename = request.ServerVariables("URL")
filename = filename.substring(filename.lastIndexOf("//"))

I'm thinking .net and it's not working saying that i need an object on the last line.

The third line returns
I want to get that down to just mypage.asp

Michael Hsu

Reply With Quote
  #2 (permalink)  
Old July 3rd, 2005, 02:52 AM
Friend of Wrox
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts

I think there is issue with
filename = filename.substring(filename.lastIndexOf("//"))

If you are using vbscript, then above statement is not correct.

One approach can be:
filename = split(filename,"/")
Response.Write filename(uBound(filename))
In above example, you need to check for empty string and uBound as well.

Om Prakash
Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
strip html tags with xslt smiter XSLT 4 June 19th, 2012 08:34 AM
how do i remove the page/filename from my URL? panuvin ASP.NET 2.0 Basics 2 September 21st, 2007 09:12 AM
progress bar on status strip malikabid VB How-To 2 September 9th, 2006 03:28 AM
Want to Strip Chars from a String - Not Working WebDevel Javascript How-To 2 January 10th, 2004 01:08 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.