#include "boost/algorithm/string.hpp"
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using namespace boost;
int main(int argc,char* argv[])
{
/*template<typename SequenceSequenceT, typename RangeT, typename PredicateT>
SequenceSequenceT &
split(SequenceSequenceT &, RangeT &, PredicateT,
token_compress_mode_type = token_compress_off);*/
typedef vector<string> VECSTRING;
VECSTRING vecDemo;
string strDemo = "test1^&^arc2^&^asd3";
split(vecDemo,strDemo,is_any_of("^&^"),token_compress_on);
/*
string strDemo = "1^2^3";
split(vecDemo,strDemo,is_any_of("^"),token_compress_off);*/
VECSTRING::iterator iter;
for(iter = vecDemo.begin(); iter != vecDemo.end(); ++iter)
{
printf("%s\n",(*iter).c_str());
}
return 0;
}
boost::split
最新推荐文章于 2024-08-12 17:01:58 发布
本文介绍了一个使用Boost库进行字符串分割的例子。通过定义一个字符串并利用Boost算法库中的split函数,根据指定的分隔符将字符串分割成多个部分,并存储到一个vector容器中。最后遍历容器打印出每个分割后的子串。

1万+

被折叠的 条评论
为什么被折叠?



