#include <boost/algorithm/string.hpp>

首先是盘点子串是否是父串的一个子串。

如下所示:

    std::string str("I Don't Know.\n");
    std::cout << boost::to_upper_copy(str);
    std::cout << str ;
    boost::to_lower(str);
    std::cout << str;
    std::string str("Power Bomb");
    if (boost::iends_with(str, "bomb"))
    {
        std::cout << "bomb\n";
    }
    if (!boost::ends_with(str, "bomb"))
        std::cout << "no bomb\n" ;
    if (boost::starts_with(str, "Pow"))
        std::cout << "start Pow" << std::endl;
    if (boost::contains(str, "er"))
        std::cout << "contains er\n";
    std::string str2 = boost::to_lower_copy(str);
    if (boost::iequals(str, str2))
        std::cout << "iequal" << std::endl;
    std::string str3("power suit");
    if (boost::lexicographical_compare(str, str3))
    {
        std::cout << "litter\n";
    }
    if (boost::all(str2.substr(0, 5), boost::is_lower()))
        std::cout << "is low" << std::endl;
View Code

相关文章: