By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Strip extension function

P: n/a
Hi,

Is there a string function to strip the file extension from a variable
in ASP? If not any suggestions as to the best way to approach this?

Cheers...John
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jo***********@yahoo.co.uk (John Aspinall) wrote:
Hi,

Is there a string function to strip the file extension from a variable
in ASP? If not any suggestions as to the best way to approach this?


Use the InStrRev function
(http://msdn.microsoft.com/library/de...ctinstrrev.asp)
to find the last ".". Then remove that and everything after it.

--
Tim Slattery
MS MVP(DTS)
Sl********@bls.gov
Jul 22 '05 #2

P: n/a
John Aspinall wrote on 17 nov 2004 in
microsoft.public.inetserver.asp.general:
Is there a string function to strip the file extension from a variable
in ASP? If not any suggestions as to the best way to approach this?


ASP is not a language, but a platform for script languages.

ASP vbscript:

function stripExt(x)
n = InStrRev(s,".")
if n>0 then
stripExt = left(s,n-1)
else
stripExt = x
end if
end function
ASP jscript:

function stripExt(x){
return x.replace(/\.[^\.]*$/,'')
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.