Regular expression to remove a file's extension

Viewed 86244

I am in need of a regular expression that can remove the extension of a filename, returning only the name of the file.

Here are some examples of inputs and outputs:

myfile.png     -> myfile
myfile.png.jpg -> myfile.png

I can obviously do this manually (ie removing everything from the last dot) but I'm sure that there is a regular expression that can do this by itself.

Just for the record, I am doing this in JavaScript

9 Answers
  return filename.split('.').pop();

it will make your wish come true. But not regular expression way.

Related