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=).

Parameters

none

Return value

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

Example

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


Output:
first is not case insensitive.
second is case insensitive.

See also