Regex for extracting filename from path

前端 未结 17 657
时光取名叫无心
时光取名叫无心 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:46

    This regular expression extract the file extension, if group 3 isn't null it's the extension.

    .*\\(.*\.(.+)|.*$)
    

提交回复
热议问题