I had missed it because I searched for an index
method, but it's right there as a method - std::tr1::smatch::position()
will give the index of the match.
Get index of match from tr1::regex_search
Question
How can I get the index of the match when using std::tr1::regex_search
?
// sequence of string sub-matches
std::tr1::smatch result;
if (!std::tr1::regex_search(text, result, pattern))
return false;
I can get only the string from the std::tr1::smatch result
variable, but not the index of the match.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow