Hello. There is the following example:
#include <iostream> #include <regex> int main() { std::string str("subject, subbase"); std::regex rx("sub\\w*"); std::smatch res; std::regex_search(str, res, rx); for(auto &i: res) { std::cout << i << " "; } return 0; } Output: subject
I was expecting the output of both words from str , and then both words highlight me. G ++ (GCC) 6.1.1. Maybe I did not understand correctly the principle of the function regex_search? It should make all the matches in res, everything seems to be correct.