Xpode.com        Click here to Print this article.

how to extract extension from filename string in javascript

We can find any file extension with function. It will split the characters from last dot and show all characters after that. Please see below working example.

var fileExt = filename.split('.').pop();
If there will be no “.” Dot in value then it will show entire string.

Examples:

'some_value' = 'some_value'

'.html = 'html'

'../images/myimage.cool.jpg' = 'jpg'

http://
http://

Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=595

Click here to go on website