#include<iostream>
#include<regex>
using namespace std;

int main() {
    string s = "foo:12,bar:456,b:az:0,";
    regex c("([^,]+?):([0-9]+)");
    int matches = 0;
    smatch sm;
    sregex_iterator iter(s.begin(), s.end(), c); std::sregex_iterator end;   
    while(iter != end) { 
    	sm = *iter;
        cout << "grp1 - " << sm[1].str() << ",   grp2 - " << sm[2].str() << endl; 
        matches++;
        ++iter; 
    }
    cout << "Matches: " << matches << endl; 
}