I would like to extract a substring between two others. ex: /home/toto/FILE_mysymbol_EVENT.DAT or just FILE_othersymbol_EVENT.DAT And I
/home/toto/FILE_mysymbol_EVENT.DAT
FILE_othersymbol_EVENT.DAT
I would study corner cases before trusting it, but
std::string text = "/home/toto/FILE_mysymbol_EVENT.DAT"; std::regex re("(.*)(FILE_)(.*)(_EVENT.DAT)(.*)"); std::cout << std::regex_replace(text, re, "$3") << '\n';
is a good candidate.