#include #include #include const std::string find_exp = "(?s)(?x)(?<=<(?'maintag'italic)>)(?'main'\\((?'innertext'(?>(?|(?:(?:(?![()])(?!<(?!WRK)\\b)(?!]*+>(?'tagbody'(?>(?:(?!<\\k'tagname'\\b)(?!]*+>(?&tagbody))*+))?)|(?:<(?'tagname'\\w++)[^>]*+>(?'tagbody'(?>(?:(?!<\\k'tagname'\\b)(?!]*+>(?&tagbody))*+))|(?&main)))*+)\\))(?=)"; const std::string replace_exp = "~~$+{innertext}~~"; const std::string search_in = "The third and final section, (Part (III)), consists of the following appendixes"; int test() { boost::u32regex expr = boost::make_u32regex(find_exp); boost::u32regex_iterator match(search_in.begin(), search_in.end(), expr); boost::u32regex_iterator end; for (; match != end; ++match) { boost::match_results result = *match; std::cout << "hit" << std::endl; std::string replace_str = result.format(replace_exp, boost::format_perl); std::cout << replace_str << std::endl; } std::cout << "Finished!" << std::endl; return 0; } int main() { return test(); }