Boost库之字符串处理

时间:2022-09-09 00:00:46

equals

    assert(boost::equals("boost", "boost"));  
assert(!boost::equals("boost", "BOOST"));
assert(boost::iequals("boost", "BOOST"));

all ,  如果它的所有元素满足一个给定的通过判断式描述的条件,则这个条件式成立。

    assert(boost::all("\x20\t\n\r", boost::is_space()));   
assert(boost::all("\x20\t\n\r", boost::is_classified(std::ctype_base::space)));
assert(boost::all("\x20\t\n\r", boost::is_any_of("\x20\t\n\r")));
assert(boost::all("abcde", boost::is_from_range('a','e')));
assert(boost::all("abcde", boost::is_from_range('a','z')));
assert(!boost::all("abcde", boost::is_from_range('b','c')));
assert(boost::all("abc __ de", boost::is_from_range('a','z') || boost::is_space() || boost::is_any_of("_")));
starts_with

    assert(boost::starts_with("boost_python-vc100-mt-1_49.dll", "boost"));  
assert(!boost::starts_with("boost_python-vc100-mt-1_49.dll", "BOOST"));
assert(boost::istarts_with("boost_python-vc71-mt-1_33.dll", "BOOST"));
ends_with

    assert(boost::ends_with("boost_python-vc100-mt-1_49.dll", ".dll"));  
assert(!boost::ends_with("boost_python-vc100-mt-1_49.dll", ".DLL"));
assert(boost::iends_with("boost_python-vc100-mt-1_49.dll", ".DLL"));
contains

    assert(boost::contains("boost_python-vc100-mt-1_49.dll", "python"));  
assert(!boost::contains("boost_python-vc100-mt-1_49.dll", "PYTHON"));
assert(boost::icontains("boost_python-vc100-mt-1_49.dll", "PYTHON"));
is_space: 字符是否为空格  
is_alnum: 字符是否为字母和数字字符  
is_alpha: 字符是否为字母  
is_cntrl: 字符是否为控制字符  
is_digit: 字符是否为十进制数字  
is_graph: 字符是否为图形字符  
is_lower: 字符是否为小写字符  
is_print: 字符是否为可打印字符  
is_punct: 字符是否为标点符号字符  
is_upper: 字符是否为大写字符  
is_xdigit: 字符是否为十六进制数字  
is_any_of: 字符是否是参数字符序列中的任意字符  
is_from_range 字符是否位于指定区间内,即from <= ch <= to