Regular expression to remove a file's extension

后端 未结 9 2060
死守一世寂寞
死守一世寂寞 2020-11-30 01:09

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:<

9条回答
  •  一个人的身影
    2020-11-30 01:57

    This will do it as well :)

    'myfile.png.jpg'.split('.').reverse().slice(1).reverse().join('.');
    

    I'd stick to the regexp though... =P

提交回复
热议问题