Skip to content

Instantly share code, notes, and snippets.

@jeshuamaxey
Created July 19, 2013 18:09
Show Gist options
  • Save jeshuamaxey/6041151 to your computer and use it in GitHub Desktop.
Save jeshuamaxey/6041151 to your computer and use it in GitHub Desktop.
A JavaScript function which removes all compounded file extensions of a string eg "file.js" => "file" "file.min.js" => "file" "file.v.0.04.min.js" => "file"
function removeExt(string) {
if(string == string.replace(/\.[^/.]+$/, ''))
return string;
else
return removeExt(string.replace(/\.[^/.]+$/, ''));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment