
Hi there, I am going to retrieve the following pattern %K{xxx} where xxx can be anything except line break. I find and modify the following code from document, is that right for my case? boost::regex expK("[^%]*%K{([^\r\n])}"); std::string::const_iterator start, end; start = sourcesrc.begin(); end = sourcesrc.end(); boost::match_resultsstd::string::const_iterator what; boost::match_flag_type flags = boost::match_default; while ( regex_search(start, end, what, expK, flags) ) { // handle the match string, i.e. xxx my_fun( std::string( what[1].first, what[1].second ) ); start = what[1].second; flags |= boost::match_prev_avail; flags |= boost::match_not_bob; } Here, expK found all the substring matching %K{xxx} (not including double % case). But the program didn't give me what I want, I guess the problem is from the expression where { and } is not expressed correctly. However, I didn't found how to express { and } in the document. Here is my guess of the correct form, tell me if it is correct or not 1) boost::regex expK("[^%]*%K\{([^\r\n])\}"); // here \{ represents { and \} represents } 2) boost::regex expK("[^%]*%K[{]{1}([^\r\n])[}]{1}"); // use [{]{1} and [}]{1} to limit the { and } occur once exactly 3) boost::regex expK("[^%]*%K\\{([^\r\n])\\}"); // here \\{ represents { and \\} represents } which one is correct? or all is wrong? Please help! Thanks in advance.