0

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.

sashoalm
  • 75,001
  • 122
  • 434
  • 781

1 Answers1

1

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.

sashoalm
  • 75,001
  • 122
  • 434
  • 781