Regular expression to remove a file's extension

后端 未结 9 2056
死守一世寂寞
死守一世寂寞 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:31

    In javascript you can call the Replace() method that will replace based on a regular expression.

    This regular expression will match everything from the begining of the line to the end and remove anything after the last period including the period.

    /^(.*)\..*$/
    

    The how of implementing the replace can be found in this Stackoverflow question.

    Javascript regex question

提交回复
热议问题