Я использую Named Capture Groups с Повышением Regex / Xpressive.
Я хотел бы выполнить итерации по всем подсоответствиям и получить и значение и КЛЮЧ каждого подсоответствия (т.е. что ["тип"]).
sregex pattern = sregex::compile( "(?P<type>href|src)=\"(?P<url>[^\"]+)\"" );
sregex_iterator cur( web_buffer.begin(), web_buffer.end(), pattern );
sregex_iterator end;
for( ; cur != end; ++cur ){
smatch const &what = *cur;
//I know how to access using a string key: what["type"]
std::cout << what[0] << " [" << what["type"] << "] [" << what["url"] <<"]"<< std::endl;
/*I know how to iterate, using an integer key, but I would
like to also get the original KEY into a variable, i.e.
in case of what[1], get both the value AND "type"
*/
for(i=0; i<what.size(); i++){
std::cout << "{} = [" << what[i] << "]" << std::endl;
}
std::cout << std::endl;
}