Regex for extracting filename from path

前端 未结 17 706
时光取名叫无心
时光取名叫无心 2020-12-03 01:02

I need to extract just the filename (no file extension) from the following path....

\\\\my-local-server\\path\\to\\this_file may_contain-any&character.pdf<

17条回答
  •  囚心锁ツ
    2020-12-03 01:51

    This is just a slight variation on @hmd's so you don't have to truncate the .

    [ \w-]+?(?=\.)
    

    Demo

    Really, thanks goes to @hmd. I've only slightly improved on it.

提交回复
热议问题