std::regex_..._collatename(3)
β¨ NAME β¨
std::regex_traits::lookup_collatename β std::regex_traits::lookup_collatename
okay so this is the std::regex_..._collatename(3) page from the C++ Standard Libary, and bestie, itβs literally all about std::regex_traits::lookup_collatename. π«Ά
πΈ Synopsis πΈ
template< class ForwardIt >
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, it returns the name of that collating element. Otherwise, it returns an empty string. No cap. β¨
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. Itβs giving very specific locale behavior. π
π Parameters π
first,lastβ a pair of iterators which determines the sequence of characters that represents a collating element name. thatβs the whole parameter moment.
π¦ Type requirements π¦
ForwardItmust meet the requirements ofLegacyForwardIterator. periodt.
π Return value π
The representation of the named collating element as a character string. slay.
π Example π
Run this code, bestie (// Run this code energy): β¨
#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
thatβs the possible output, fr fr. π
mwah π source is http://cppreference.com, version/date is 2024.06.10, and the page is std::regex_..._collatename(3). bye bestie π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms