Created
September 24, 2021 12:29
-
-
Save WebSofter/40eccfadb4551d306a4e309db6baf7b6 to your computer and use it in GitHub Desktop.
Get file extension in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFileExtension(filename){ | |
let ext = /^.+\.([^.]+)$/.exec(filename) | |
return ext == null ? '' : ext[1].length < 5 ? ext[1] : ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment