1、下载zip文件 解压到 d:\boost_1_45_0

2、运行bootstrap.bat 编译出 bjam.exe

3、改D:\boost_1_45_0\tools\build\v2\user-config.jam

找到如下所示的字符串。

 #  MSVC configuration 

  #  Configure msvc (default version, searched in standard location 

#  and PATH). 

#  using msvc ; 

  在此字符串下面添加如下命令行,并保存。

 using msvc : 9.0 : : /wd4819 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE  /D_SECURE_SCL=0 ; 


bjam --without-python --toolset=msvc-9.0 --prefix=d:\develop\boost install


5、设置开发环境

打开VS2008 选择 工具->选项->vc++目录

设置包含文件目录D:\develop\boost\include\boost-1_45

设置引用文件目录:d:\develop\boost\lib

 

 

#include <cstdlib>
#include <stdlib.h>
#include <boost/regex.hpp>
#include <string>
#include <iostream>

using namespace std;
using namespace boost;

regex expression("^select ([a-zA-Z]*) from ([a-zA-Z]*)");

int main(int argc, char* argv[])
{
	std::string in;
	cmatch what;
	cout << "enter test string" << endl;
	getline(cin,in);
	if(regex_match(in.c_str(), what, expression)) {
		for(int i=0;i<(int)what.size();i++)
			cout<<"str :"<<what[i].str()<<endl;
	} else {
		cout<<"Error Input"<<endl;
	}

	while(1);
	return 0;
}