public member function
<regex>

std::match_results::end

const_iterator begin() const;
Return iterator to end
Returns an iterator pointing to the past-the-end match in the match_results object. Together with match_results::begin, these functions describe a range that encompasses all the matches in the match_results object.

If the match_results object is empty (i.e., the expression did not match), the value returned by end is the same as the one returned by begin, representing an empty range, and shall not be dereferenced.

If the match_results object is not ready, the value returned by this function may bear no relation with that of begin, and thus shall not be used to specify a range. It shall neither be dereferenced.

Parameters

none

Return value

An iterator to to the sub_match past-the-end location in the sequence of matches in the match_results object.

Member type const_iterator (the same as member type iterator) is a forward iterator type.
The matches contained in a match_results object are always const.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// match_results::begin/end
// - using smatch, a standard alias of match_results<string::iterator>
#include <iostream>
#include <string>
#include <regex>

int main ()
{
  std::string s ("subject");
  std::smatch m;
  std::regex e ("(sub)(.*)");

  std::regex_match ( s, m, e );

  std::cout << "matches:" << std::endl;
  for (std::smatch::iterator it = m.begin(); it!=m.end(); ++it) {
	std::cout << *it << std::endl;
  }
  return 0;
}

Output:
matches:
subject
sub
ject



See also