Regex match take a very long time to execute

前端 未结 4 1037
轻奢々
轻奢々 2020-12-18 06:08

I wrote a regular expression that parses a file path into different group (DRIVE, DIR, FILE, EXTENSION).

^((?[a-zA-Z]):\\\\)*((?[a-zA         


        
4条回答
  •  情歌与酒
    2020-12-18 06:34

    Why not just use System.IO.Path functions?

    • Drive: http://msdn.microsoft.com/en-us/library/system.io.path.getpathroot.aspx

    • Directory: http://msdn.microsoft.com/en-us/library/system.io.path.getdirectoryname.aspx minus what is gotten for Drive

    • Filename: http://msdn.microsoft.com/en-us/library/system.io.path.getfilenamewithoutextension.aspx

    • Extension: http://msdn.microsoft.com/en-us/library/system.io.path.getextension.aspx

提交回复
热议问题