boost

    技术2023-01-20  18

     

    1.从官方网站下载boost_1_45_0 http://sourceforge.net/projects/boost/files/boost/1.45.0/boost_1_45_0.zip

     

    2.加压到F:/boost_1_45_0

     

    3.运行cmd.exe,切换到 F:/boost_1_45_0目录

     

    4.F:/boost_1_45_0>bootstrap.bat ,运行完后在 F:/boost_1_45_0目录下生成了一个bjam.exe

     

    5.F:/boost_1_45_0> bjam install --toolset=msvc-10.0 --without-python --prefix=D:/boost,运行完后在D:/boost目录下生成2个文件夹include和lib

     

    6.测试例子 在vs2010的工程属性上设置include目录和library 目录

    D:/boost/include/boost-1_45

    D:/boost/lib

     

     

    #include "stdafx.h"

    #include <cstdlib>

    #include <stdlib.h>

    #include <boost/regex.hpp>

    #include <string>

    #include <iostream>

    using  namespace std;

    using  namespace boost;

     

    int _tmain(int argc, _TCHAR* argv[])

    {

    regex expression( "(d+)-(d+)-(d+)");// 注意转义方式

    string  in("Today:2007-06-23");

    cmatch what;

    //如果用 regex_match 方法将需要完全匹配,不能在字符串中找寻模式,可用于验证输入

    if (regex_search(in.c_str(),what,expression))

    {

    for (int i=0;i<what.size();i++)

    {

    cout<<"str:"<<what[i].str()<<endl;

    }

    }

    return 0;

    }

     

     

     

     

     

     

    最新回复(0)