C++ Boost split

    技术2023-09-19  70

        #include <boost/regex.hpp>     #include <boost/algorithm/string/regex.hpp>

        std::string text = "Let//me//split//this//into//words";     std::vector<std::string> results;         boost::split_regex(results, text, boost::regex("//"));

    以上代码可以实现分割字符串,但是如果文字中不是//而是*,且分隔符是*,执行程序会报错。

    代码来源:http://www.cplusplus.com/faq/sequences/strings/split/#boost-split-regex

    Processed: 0.008, SQL: 9