hengheng123456789

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            297 Posts :: 68 Stories :: 144 Comments :: 0 Trackbacks
          轉自:http://jinyun2012.blog.sohu.com/155691639.html

          下載boost最新庫 

          安裝:
          1、打開vs2005在菜單tools中選擇Visual Studio 2005 Command Prompt,打開已配置好環境的命令行。
          2、進入目錄boost_1_34_1\libs\regex\build,
          編譯文件:nmake -f vc8.mak
          安裝(將編譯好的文件復制到vs2005的特定目錄下):nmake -f vc8.mak install
          刪除臨時文件:nmake -f vc8.mak clean
          3、Tools->Options->Projects and Solutions->VC++ Directories->Include files添加boost_1_34_1路徑

           

           在vs2005中編寫如下代碼

          #include "stdafx.h"
          #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<what.size();i++)
             cout<<"str :"<<what[i].str()<<endl;
           }
           else
           {
            cout<<"Error Input"<<endl;
           }
           return 0;
          }

           

          在提示下輸入

          enter test string
          select name from table

           

          得到如下結果,具體為什么自己認真分析
          str :select name from table
          str :name
          str :table

          posted on 2011-01-12 10:33 哼哼 閱讀(733) 評論(0)  編輯  收藏 所屬分類:
          主站蜘蛛池模板: 延寿县| 集安市| 分宜县| 重庆市| 津市市| 东乡族自治县| 中西区| 巫山县| 亚东县| 大洼县| 抚州市| 北碚区| 苍梧县| 江达县| 札达县| 桐梓县| 平原县| 无锡市| 石河子市| 伽师县| 乐亭县| 双流县| 乌拉特中旗| 焉耆| 稻城县| 顺昌县| 平安县| 阳信县| 合作市| 萝北县| 邓州市| 恭城| 铁岭县| 金川县| 松桃| 宜兰县| 大同县| 溧水县| 漳浦县| 石门县| 神农架林区|