public member function
<regex>

std::basic_regex::flags

flag_type flags() const;
Return syntax flags
Returns the syntax flags used to interpret the regular expression.

Syntax flags cannot be changed independently. They can only be set on construction or changed on an assignment operation (with either basic_regex::assign or basic_regex::operator=).

参数



返回值

The syntax flags used by the basic_regex object.
flag_typeis a member type, defined as an alias of the bitmask type regex_constants::syntax_option_type.

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// basic_regex::flags
// note: using regex, a standard alias of basic_regex<char>
#include <iostream>
#include <regex>

int main ()
{
  using namespace std::regex_constants;
  std::regex first ("[a-z]+");
  std::regex second ("[a-z]+", ECMAScript | icase );

  std::cout << "first ";
  std::cout << ( ( first.flags() & icase ) == icase ? "is":"is not");
  std::cout << " case insensitive.\n";

  std::cout << "second ";
  std::cout << ( ( second.flags() & icase ) == icase ? "is":"is not");
  std::cout << " case insensitive.\n";

  return 0;
}

输出
first is not case insensitive.
second is case insensitive.


另见