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.
Update
I compile the program on Ubuntu 14.04 with compiler flags:
CXX = clang++ WFLAGS=-Wall -Wno-deprecated-declarations -Wno-unknown-pragmas CXXFLAGS = $(WFLAGS) -Werror -g -std=c++11 -pthread
The internal abi version of libstdc++ is 3.4.19. Extracted using:
readelf -sV /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | sed -n 's/.*@@GLIBCXX_//p' | sort -u -V | tail -1
The libstdc++ version of Ubuntu 14.04 (trusty) is 4.8.2.