public member function
<regex>

std::regex_token_iterator::operator++

(1)
regex_token_iterator& operator++();
(2)
regex_token_iterator& operator++(int);
Increment regex_token_iterator
Advances the regex_token_iterator to the next submatch.

If the object was constructed to iterate over a list of more than one submatch and is currently pointing to a submatch other than the last one of that list, the function advances its internal pointer to point to the next selected submatch in the match.

Otherwise, the function performs a new search on the remainder of the target sequence by incrementing its internal regex_iterator object. If this produces an additional match, the internal pointer is set to point to its first submatch. Otherwise, the regex_token_iterator becomes an end-of-sequence iterator (except in the case that -1 is one of the selected submatches).

In the case that -1 is one of the selected submatches and the internal regex_iterator has reached the end-of-sequence, the iterator is still valid and dereferencing it will return the subsequence between the last match and the end of the target sequence. Any further increment of the iterator after that produces the iterator to become an end-of-sequence iterator.

Parameters

none (the second version is for the post-increment operator).

Return value

The pre-increment version (1) returns *this.
The post-increment version (2) returns a copy of the value of *this before the call.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// regex_iterator example
#include <iostream>
#include <string>
#include <regex>

int main ()
{
  std::string s ("this subject has a submarine as a subsequence");
  std::regex e ("\\b(sub)([^ ]*)");   // matches words beginning by "sub"

  std::regex_iterator<std::string::iterator> rit ( s.begin(), s.end(), e );
  std::regex_iterator<std::string::iterator> rend;

  while (rit!=rend) {
    std::cout << rit->str() << std::endl;
    ++rit;
  }

  return 0;
}


Output:
subject
submarine
subsequence


See also