public member function
<regex>

std::regex_iterator::operator!=

bool operator!=(const regex_iterator& rhs) const;
比較 regex_iterator 是否不相等
返回值如果 rhsregex_iterator 物件不相等。

如果以下任何一種情況為真,則兩個 regex_iterator 相等
  • 它們都是序列結束迭代器
  • 其中一個被構造為或賦值為另一個的副本,並且現在指向相同的匹配項。
  • 它們都是使用等效的 firstlastflags 引數構造的,都使用相同的 regex 物件,並且現在都指向相同的匹配項(它們的內部 match_results 物件相等)。

引數

rhs
相同型別的另一個 regex_iterator 物件。

返回值

如果兩個 regex_iterator 不相等。否則為 false。

示例

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;
}

輸出
subject
submarine
subsequence



另見