Boost::split用法详解

工程中使用boost库:(设定vs2010环境)
在Library files加上 D:\boost\boost_1_46_0\bin\vc10\lib
在Include files加上 D:\boost\boost_1_46_0

 1 // boostTest.cpp : 定义控制台应用程序的入口点。
 2 #include "stdafx.h"
 3
 4 #include <iostream>
 5 #include <boost/format.hpp>
 6 #include <boost/tokenizer.hpp>
 7 #include <boost/algorithm/string.hpp>
 8
 9 int _tmain(int argc, _TCHAR* argv[])
10 {
11     std::wcout.imbue(std::locale("chs"));
12     //待分割的字符串
13     std::wstring strTag = _T("I Come from China");
14
15     std::vector<std::wstring> vecSegTag;
16     // boost::is_any_of这里相当于分割规则了
17     boost::split(vecSegTag, strTag,boost::is_any_of(_T(" ,,")));
18
19     for (size_t i  =0;i<vecSegTag.size();i++)
20     {
21         std::wcout<<vecSegTag[i]<<std::endl;
22     }
23
24     vecSegTag.clear();
25     std::wstring strTag2 = _T("我叫小马,你呢,今天天气不错,我很高兴");
26     boost::split(vecSegTag, strTag2, boost::is_any_of(_T(" ,,")));
27
28     for (size_t i  =0 ; i<vecSegTag.size(); i++)
29     {
30         std::wcout<<vecSegTag[i]<<std::endl;
31     }
32
33     getchar();
34     return 0;
35 }
时间: 2024-08-29 05:30:51

Boost::split用法详解的相关文章

boost::algorithm用法详解之字符串关系判断

http://blog.csdn.net/qingzai_/article/details/44417937 下面先列举几个常用的: #define i_end_with boost::iends_with#define i_start_with boost::istarts_with#define i_contain boost::icontains#define i_equal boost::iequals#define split boost::algorithm::split#defin

[转] boost::function用法详解

http://blog.csdn.net/benny5609/article/details/2324474 要开始使用 Boost.Function, 就要包含头文件 "boost/function.hpp", 或者某个带数字的版本,从 "boost/function/function0.hpp" 到 "boost/function/function10.hpp". 如果你知道你想保存在 function 中的函数的参数数量,这样做可以让编译器

boost::function用法详解

要开始使用 Boost.Function, 就要包含头文件 "boost/function.hpp", 或者某个带数字的版本,从 "boost/function/function0.hpp" 到 "boost/function/function10.hpp". 如果你知道你想保存在 function 中的函数的参数数量,这样做可以让编译器仅包含需要的头文件.如果包含 "boost/function.hpp", 那么就会把其它的

boost的posix_time用法详解01

// boost_time.cpp : 定义控制台应用程序的入口点. //made by davidsu33 //2014-5-11 //the usage of posix_time #include "stdafx.h" #include <boost/date_time/posix_time/posix_time.hpp> #include <iostream> #include <cassert> using namespace std; #

C#的String.Split 分割字符串用法详解的代码

代码期间,把代码过程经常用的内容做个珍藏,下边代码是关于C#的String.Split 分割字符串用法详解的代码,应该对码农们有些用途. 1) public string[] Split(params char[] separator)2) public string[] Split(char[] separator, int count)3) public string[] Split(char[] separator, StringSplitOptions options)4) public

Delphi TStringHelper用法详解

Delphi TStringHelper用法详解 (2013-08-27 22:45:42) 转载▼ 标签: delphi_xe5 it 分类: Delphi Delphi XE4的TStringHelper,对操作字符串进一步带来更多的方法,使用这些方法才可以实现跨平台的代码. System.SysUtils.TStringHelper 大小写转换:-------------------------------------------------------------------------

Vue1.0用法详解

Vue.js 不支持 IE8 及其以下版本,因为 Vue.js 使用了 IE8 不能实现的 ECMAScript 5 特性. 开发环境部署 可参考使用 vue+webpack. 基本用法 1 2 3 4 5 6 7 8 9 10 11 <div id="app"> {{message}} <input v-model="message"> </div> new Vue({ ele: '#app', data: { message:

js的offsetParent属性用法详解

js的offsetParent属性用法详解:此属性是javascript中较为常用的属性,对于它的良好掌握也是非常有必要的,下面就通过代码实例介绍一下它的用法,希望能够给需要的朋友带来一定的帮助.一.基本介绍:此属性可以返回距离指定元素最近的采用定位(position属性值为fixed.relative或者absolute)父级元素,如果父级元素中没有采用定位的元素,则返回body对象的引用.语法结构: obj.offsetParent 二.代码实例: <!DOCTYPE html> <

python处理word文件:win32com用法详解

目标:用python处理doc文件 方法:引入win32com模块 ************************************************************************** 一.安装 ************************************************************************** 首先要先下载安装win32com模块(起先在linux下装不成功,后在windows下面成功了...) 下载地址:http