Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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'
Share this article   |    Print    |    Article read by 842 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: No related interview question