std::regex_traits<CharT>::lookup_collatename
From cppreference.com
 
 
 < cpp | regex | regex traits 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Text processing library 
 
 
 
 
 
 
 
 
 Regular expressions library (C++11)
 Formatting library (C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++26)
Regular expressions library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Classes
(C++11)
(C++11)
(C++11)
 Algorithms
(C++11)
(C++11)
(C++11)
 Iterators
(C++11)
(C++11)
 Exceptions
(C++11)
 Traits
(C++11)
 Constants
(C++11)
(C++11)
(C++11)
 Regex Grammar
(C++11)
std::regex_traits 
 
 Member functions
regex_traits::lookup_collatename
template< class ForwardIt >
string_type lookup_collatename( ForwardIt first, ForwardIt last ) const;
 
 
string_type lookup_collatename( ForwardIt first, ForwardIt last ) const;
If the character sequence [first, last) represents the name of a valid collating element in the currently imbued locale, returns the name of that collating element. Otherwise, returns an empty string.
Collating elements are the symbols found in POSIX regular expressions between [. and .]. For example, [.a.] matches the character a in the C locale. [.tilde.] matches the character ~ in the C locale as well. [.ch.] matches the digraph ch in Czech locale, but generates std::regex_error  with error code std::regex_constants::error_collate  in most other locales.
[edit] Parameters
 first, last
 -
 a pair of iterators which determines the sequence of characters that represents a collating element name
 Type requirements
 -
ForwardIt must meet the requirements of LegacyForwardIterator.
[edit] Return value
The representation of the named collating element as a character string.
[edit] Example
Run this code
#include <iostream> #include <regex> #include <string> struct noisy_traits : std::regex_traits <char> { template<class Iter> string_type lookup_collatename(Iter first, Iter last) const { string_type result = regex_traits::lookup_collatename(first, last); std::cout << "regex_traits<>::lookup_collatename(\"" << string_type(first, last) << "\") returns \"" << result << "\"\n"; return result; } }; int main() { std::string str = "z|}a"; // C locale collation order: x,y,z,{,|,},~ std::basic_regex <char, noisy_traits> re("[x-[.tilde.]]*a", std::regex::basic); std::cout << std::boolalpha << std::regex_match (str, re) << '\n'; }
Possible output:
regex_traits<>::lookup_collatename("tilde") returns "~"
true