Regex for parsing directory and filename

前端 未结 8 1554
南方客
南方客 2020-11-30 03:55

I\'m trying to write a regex that will parse out the directory and filename of a fully qualified path using matching groups.

so...

/         


        
8条回答
  •  无人及你
    2020-11-30 04:38

    Try this:

    /^(\/([^/]+\/)*)(.*)$/
    

    It will leave the trailing slash on the path, though.

提交回复
热议问题