If I have a simple regex pattern like “ab.” and I have a string that has multiple matches like “abc abd”. If I do the following…
boost::match_flag_type flags = boost::match_default;
boost::cmatch mcMatch;
boost::regex_search("abc abd", mcMatch, "ab.", flags)
Then mcMatch contains just the first “abc” result. How can I get all possible matches?
You can use the
boost::sregex_token_iteratorlike in this short example:The output from this program is: