Get a file name from a path

前端 未结 21 1575
面向向阳花
面向向阳花 2020-11-30 23:55

What is the simplest way to get the file name that from a path?

string filename = \"C:\\\\MyDirectory\\\\MyFile.bat\"

In this example, I s

21条回答
  •  北海茫月
    2020-12-01 00:29

    A slow but straight forward regex solution:

        std::string file = std::regex_replace(path, std::regex("(.*\\/)|(\\..*)"), "");
    

提交回复
热议问题