RegEx that will match the last occurrence of dot in a string

前端 未结 9 1187
梦如初夏
梦如初夏 2020-12-13 16:55

I have a filename that can have multiple dots in it and could end with any extension:

tro.lo.lo.lo.lo.lo.png

I need to use a regex to repla

9条回答
  •  执笔经年
    2020-12-13 17:35

    You could simply do like this,

    > "tro.lo.lo.lo.lo.lo.zip".replace(/^(.*)\./, "$1@2x");
    'tro.lo.lo.lo.lo.lo@2xzip'
    

提交回复
热议问题