regex to remove everything after the last dot in a file

后端 未结 2 1655
庸人自扰
庸人自扰 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:24

    Try following regex for search and replace

    s/\.[^.]*$/\./
    
    0 讨论(0)
  • 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:

    (?<=\.)[^.]*$
    
    0 讨论(0)
提交回复
热议问题