regex to remove everything after the last dot in a file

后端 未结 2 1657
庸人自扰
庸人自扰 2021-01-03 18:54

I\'m trying to find a regex for removing everything after the last dot in a file. So far I\'ve found ways to remove all text before the first dot, but I can\'t seem to find

2条回答
  •  旧巷少年郎
    2021-01-03 19:35

    You can try something like:

    \.[^.]*$
    

    to match everything including and after the last dot. If you don't want to include the last dot, then you can use a positive lookbehind:

    (?<=\.)[^.]*$
    

提交回复
热议问题