jeudi 16 avril 2015

C++11 std::regex_replace usage

I've been trying to understand the behavior of the following simple regex command when using std::regex_replace. I'm trying to extract the filename on a linux system from a full path.



std::string fullPath = "/folder/subfolder/fname.xyz";
std::string fname = std::regex_replace( fullPath, std::regex( std::string(".*/")), std::string(""));


Where fname becomes an empty string. Is this expected behavior of std::regex_replace? I would have expected fname to be "fname.xyz" after the calls.


Aucun commentaire:

Enregistrer un commentaire