I have this code snippet that I derived from something that I found online:
std::regex pieces_regex("([a-z]+)\\.([a-z]+)", std::regex_constants::basic);
std::smatch pieces_match;
std::string fname = "foo.txt";
cout << " fname " << fname << endl;
if (std::regex_match(fname, pieces_match, pieces_regex)) {
std::cout << fname << '\n';
for (size_t i = 0; i < pieces_match.size(); ++i) {
std::ssub_match sub_match = pieces_match[i];
std::string piece = sub_match.str();
std::cout << " submatch " << i << ": " << piece << '\n';
}
}
the pieces_regex constructor didn't work with my compiler, so I had to change the line from
std::regex pieces_regex("([a-z]+)\\.([a-z]+)");
to
std::regex pieces_regex("([a-z]+)\\.([a-z]+)", std::regex_constants::basic);
My regex_match line doesn't return anything now, and the size of pieces_match is zero. I tried adding several different flags to regex_match, like basic or match_any, but it didn't help. The original code can be found here: http://en.cppreference.com/w/cpp/regex/regex_match
Anyone have an idea what I'm missing?
Thanks!