JavaScript - Get Filename and Extension from URL
Posted: 03 May 2015, 14:51
Hello
How can I get the filename and extension from a variale with an URL address in JavaScript?
The URL can be any kind of webpage address; with or without ?query and #hash, for example:
Also, without extension
- I want to get separately the "filename" and "ext" (if exists).
Any code example or ideea?
Thanks.
How can I get the filename and extension from a variale with an URL address in JavaScript?
The URL can be any kind of webpage address; with or without ?query and #hash, for example:
Code: Select all
http://a.com/b/filename.ext
http://a.com/b/filename.ext#hash
http://a.com/b/filename.ext?query
http://a.com/b/filename.ext?query#hash
Code: Select all
http://a.com/b/filename
http://a.com/b/filename#hash
http://a.com/b/filename?query
http://a.com/b/filename?query#hash
Any code example or ideea?
Thanks.