public member function
<regex>

std::regex_token_iterator::operator!=

bool operator!=(const regex_iterator& rhs) const;
Compare regex_token_iterator for inequality
返回值trueif rhs does not compare equal to the regex_token_iterator object.

Two regex_token_iterator compare equal if any of these is true
  • 它们都是序列结束迭代器
  • One was constructed as or assigned to a copy of the other and are now pointing to the same submatch.
  • They were both constructed with equivalent arguments for first, last, submatch(es) and flags, both use the same regex object, and both now point to the same submatch.

参数

rhs
Another regex_token_iterator object of the same type.

返回值

trueif both regex_token_iterator do not compare equal.false否则为 false。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// regex_token_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_token_iterator<std::string::iterator> rend; // end-of-sequence iterator

  // iterate over second submatches of each match:
  std::regex_token_iterator<std::string::iterator> rit ( s.begin(), s.end(), e, 2 );

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

  return 0;
}

输出
ject
marine
sequence


另见