C++ Boost split_regex 分割字符串(记录)

    #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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章