#include #include "boost/regex.hpp" void boostTest() { std::string toTest = "abc12345123"; std::string regstr = "<(?NPC)>((?<\k>)|>(?<-Nested>)|.*?)*>"; boost::smatch what; boost::regex expr(regstr); std::string::const_iterator start = toTest.begin(); std::string::const_iterator end = toTest.end(); int pos = 0; while (boost::regex_search(start, end, what, expr)) { std::cout << "Match group " << ++pos << ":" << std::endl; for (int i = 0; i < what.size(); i++) { std::string msg(what[i].first, what[i].second); std::cout << i << ": " << msg.c_str() << std::endl; } start = what[0].second; } } int main() { boostTest(); return 0; }