• Boost String Algorithms Library 函数详解二 (predicate)


    Table 11.3. Predicates

    Algorithm nameDescriptionFunctions
    starts_with Check if a string is a prefix of the other one starts_with()
    istarts_with()
    ends_with Check if a string is a suffix of the other one ends_with()
    iends_with()
    contains Check if a string is contained of the other one contains()
    icontains()
    equals Check if two strings are equal equals()
    iequals()
    all Check if all elements of a string satisfy the given predicate all()


    基础示例:

     1     //starts
     2     assert(starts_with("boost_python-vc71-mt-1_33.dll""boost"));
     3     assert(!starts_with("boost_python-vc71-mt-1_33.dll""BOOST"));
     4     assert(istarts_with("boost_python-vc71-mt-1_33.dll""BOOST"));
     5     //ends
     6     assert(ends_with("boost_python-vc71-mt-1_33.dll"".dll"));
     7     assert(!ends_with("boost_python-vc71-mt-1_33.dll"".DLL"));
     8     assert(iends_with("boost_python-vc71-mt-1_33.dll"".DLL"));
     9     //contains    
    10     assert(contains("boost_python-vc71-mt-1_33.dll""python"));
    11     assert(!contains("boost_python-vc71-mt-1_33.dll""PYTHON"));
    12     assert(icontains("boost_python-vc71-mt-1_33.dll""PYTHON"));
    13     //equals
    14     assert(equals("boost""boost"));
    15     assert(!equals("boost""BOOST"));
    16     assert(iequals("boost""BOOST"));
    17     //Empty string test
    18     assert(starts_with("boost_python-vc71-mt-1_33.dll"""));
    19     assert(ends_with("boost_python-vc71-mt-1_33.dll"""));
    20     assert(contains("boost_python-vc71-mt-1_33.dll"""));
    21     //all
    22     assert(all("\x20\t\n\r", is_space())); 
    23     assert(all("\x20\t\n\r", is_classified(std::ctype_base::space)));
    24     assert(all("\x20\t\n\r", is_any_of("\x20\t\n\r")));
    25     assert(all("abcde", is_from_range('a','e')));
    26     assert(all("abcde", is_from_range('a','z')));
    27     assert(!all("abcde", is_from_range('b','c')));
    28     assert(all("abc __ de", is_from_range('a','z'|| is_space() || is_any_of("_")));
    29     


    在前面都没有详细说明is_xxxx是哪些函数,下面列出:

     1               is_space // 空格 
     2               is_alnum // 字母和数字 
     3               is_alpha // 字母 
     4               is_cntrl // 控制字符 
     5               is_digit // 数字 
     6               is_graph // 可打印字符(不含空格) 
     7               is_lower // 小写 
     8               is_print // 可打印字符(含空格) 
     9               is_punct // 标点 
    10               is_upper // 大写 
    11               is_xdigit // 16进制数字
    12               is_any_of // 
    13               is_from_range //
  • 相关阅读:
    Memcached基本架构和思想
    varnish和squid的对比
    常用排序讲解
    数据结构堆的一种比较明白的讲解
    磁盘挂载MOUNT 445问题集
    mysql 如何提高批量导入的速度
    云平台涅槃重生计划
    NumPy、SciPy 等Python包在Windows下的whl安装包下载
    表迁移工具的选型-复制ibd的方法
    下一步的技术研究方向
  • 原文地址:https://www.cnblogs.com/lzjsky/p/1934804.html
Copyright © 2020-2023  润新知