I have a list of filenames like
index.min.html
index.dev.html
index.min.js
index.dev.js
There.are.also.files.with.multiple.dots.and.other.extension
I want to cut off the extensions of the filenames, but the problem is that I can only use match
for this task.
I tried many regular expressions looking like "index.min.html".match( /^((?!:(\.[^\.]+$)).+)/gi );
to select the filename without the last dot and extension, but they selected either the hole filename, nothing or the part before the first dot. Is there a way to select only the filename without extension?
Why regex? Simple substring expressions make this a lot simpler:
var filename = 'index.something.js.html';
alert(filename.substr(0, filename.lastIndexOf(".")));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With