Last active
October 2, 2021 17:08
-
-
Save jhonsore/b636f7461e69399907bfd06ce64feb94 to your computer and use it in GitHub Desktop.
Get file extension
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
// methood 1 | |
function getFileExtension(filename:string) { | |
return filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2); | |
} | |
// method 2 | |
function getFileExtension(filename:string) { | |
filename.substring(filename.lastIndexOf('.')+1); | |
} |
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 getFileName(name:string){ | |
return name.replace(/\.[^/.]+$/, ""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment