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

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