std::regex_traits::lookup_collatename
| template< class ForwardIt > string_type lookup_collatename( ForwardIt first, ForwardIt last ) const; |  |  | 
|---|
如果字符序列[first, last)表示当前注入的区域设置中有效排序规则元素的名称,返回该排序规则元素的名称。否则,返回空字符串。
排序元素是在POSIX之间的正则表达式中找到的符号。[.和.]例如,[.a.]匹配字符a在C区。[.tilde.]匹配字符~在C语言环境中也是如此。[.ch.]匹配有向图ch在捷克语言环境中,但是生成std::regex_error错误码std::regex_constants::error_collate在大多数其他地方。
参数
| first, last | - | a pair of iterators which determines the sequence of characters that represents a collating element name | 
|---|
类型要求
---。
返回值
命名排序规则元素的表示形式为字符串。
例
二次
#include <iostream>
#include <string>
#include <regex>
 
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';
}二次
产出:
二次
regex_traits<>::lookup_collatename("tilde") returns "~"
true二次
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

