i want to extract all dash separated digits ( like this 232-65 ) from string in c++ using boost regex
i use this pattern
\\d*-\\d*
but only first match is detected. what should i do to extract all matched pattern.
example input :
"2 1 5-25 37 42 43 53 69-119 123-514"
out put is only 5-25 but must be 5-25 69-119 123-514
my sample code is
cmatch res;
boost::regex port("\\d*-\\d*");
regex_search(s,res, port);
for (unsigned int i = 0; i < res.size(); ++i) {
cout << res[i] << endl;
}
This is for C++11, but you should be able to replace the
std::withboost::to make it work with BoostTaken from Boost C++ regex – how to get multiple matches
If you want to use
const char*it should be: