public member function
<regex>

std::basic_regex::getloc

locale_type getloc() const;
Get locale
Returns the locale object associated with the basic_regex.

The value returned is the object set in the last call to basic_regex::imbue, or the locale by default if regex::imbue has not been called on the object (this is locale::global for objects using the standard regex_traits).

Parameters

none

Return value

The locale object associated with the regex.
locale_type is a member type, defined as an alias of its regex traits' homonymous type, which for the standard regex_traits is the standard locale type.

Example

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

int main ()
{
  std::regex myregex;
  std::locale mylocale ("");
  myregex.imbue (mylocale);
  myregex.assign ("sub[a-z]*");
  
  if (std::regex_match ("subject", myregex))
    std::cout << "The string matches";
  else
    std::cout << "The string does not match";

  std::cout << " using locale: " << myregex.getloc().name() << std::endl;

  return 0;
}

Possible output:
The string matches using locale: en-US


See also