Last active
June 24, 2024 07:37
-
-
Save stewartduffy/481f21ea4906e611d934 to your computer and use it in GitHub Desktop.
Regex to remove file extension from JS string.
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
var filenameFull = "tm_icons.png"; | |
//Regex to remove | |
var filenameText = filenameFull.replace(/\.[^/.]+$/, ""); |
I would prefer simpler way:
var fileNameFull = "temp.icon.png";
var fileNameWithoutExtension = fileNameFull.substring(0, fileNameFull.lastIndexOf("."));
// result: temp.icon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!