Regex: Get Filename Without Extension in One Shot?

后端 未结 7 1792
萌比男神i
萌比男神i 2020-12-03 03:20

I want to get just the filename using regex, so I\'ve been trying simple things like

([^\\.]*)

which of course work only if the filename ha

7条回答
  •  生来不讨喜
    2020-12-03 04:12

    I used this pattern for simple search:

    ^\s*[^\.\W]+$
    

    for this text:

    file.ext
       fileext
    
       file.ext.ext
     file.ext
    fileext
    

    It finds fileext in the second and last lines.
    I applied it in a text tree view of a folder (with spaces as indents).

提交回复
热议问题