public member function
<regex>

std::basic_regex::imbue

locale_type imbue (locale_type loc);
Imbue locale
Associates loc to the basic_regex object and resets the regular expression.

Internally, this function calls the imbue member of the regex traits object stored internally.

This function resets the basic_regex object, so it no longer matches any character sequence (as if constructed with regex's default constructor). You can use basic_regex::assign or basic_regex::operator= to assign a new regular expression pattern to the object once imbued.

On construction, a basic_regex object that uses the default regex_traits uses the global locale (locale::global).

Parameters

loc
Locale object to be imbued as the new locale for the basic_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.

Return value

The locale object associated with the basic_regex before the call.
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
// basic_regex::imbue
// note: using regex, a standard alias of basic_regex<char>
#include <iostream>
#include <regex>
#include <locale>

int main ()
{
  std::regex myregex;

  myregex.imbue (std::locale::classic());
  myregex.assign ("sub[a-z]*");
  
  if (std::regex_match ("subject", myregex))
    std::cout << "The string matches." << std::endl;

  return 0;
}


Output:
The string matches.

See also