Created
November 4, 2019 03:25
-
-
Save nivrith/8489ed0b6c41aed37a6c02f904d4b96d to your computer and use it in GitHub Desktop.
Get File extension from filename
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
const fileExt = filename => { | |
const ext = f => (/[.]/.exec(f)) ? /[^.]+$/.exec(f) : RegExp(f).exec(f); | |
const resultExp = ext(filename); | |
return resultExp ? resultExp[0] : filename; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment