boost split字符串

来源:互联网 发布:奥丁格淘宝京东价格 编辑:程序博客网 时间:2024/05/10 18:39

boost split string , which is very convenience 

#include <string>#include <iostream>#include <boost/format.hpp>#include <boost/tokenizer.hpp>#include <boost/algorithm/string.hpp>int _tmain(int argc, _TCHAR* argv[]){std::wcout.imbue(std::locale("chs"));    // 待分割的字符串std::wstring strTag = _T("I Come from China");std::vector<std::wstring> vecSegTag;     // boost::is_any_of这里相当于分割规则了boost::split(vecSegTag, strTag,boost::is_any_of(_T(" ,,")));for (size_t i  =0;i<vecSegTag.size();i++){std::wcout<<vecSegTag[i]<<std::endl;}vecSegTag.clear();std::wstring strTag2 = _T("我叫小明,你呢,今天天气不错");boost::split(vecSegTag, strTag2, boost::is_any_of(_T(" ,,")));for (size_t i  =0;i<vecSegTag.size();i++){std::wcout<<vecSegTag[i]<<std::endl;}getchar();return 0;}


原创粉丝点击