Problem:
I know I can get the file name by this:
std::string wholePath = "/User/home/Lib/hello.cpp.h";
std::regex e(".*\\/(.*)\\..*$");
std::smatch sm;
std::regex_match(wholePath.cbegin(), wholePath.cend(), sm, e);
std::cout << "File Name is : " << sm[1];
But I don't know how to get the file name from this:
std::string wholePath = "\User\home\Lib\hello.cpp.h";
std::regex e_1(".*\(.*)\\..*$");
std::regex e_2(".*\\(.*)\\..*$");
std::regex e_3(".*\\\(.*)\\..*$");
std::regex e_4(".*\\\\(.*)\\..*$");
std::smatch sm;
// std::regex_match(wholePath.cbegin(), wholePath.cend(), sm, e);
I have tried the above four expressions and they are not working.
My question, How to match the char '\'.
Help /.\