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)  編輯  收藏 所屬分類:
          主站蜘蛛池模板: 钦州市| 岚皋县| 安平县| 翁牛特旗| 梅州市| 新宁县| 靖远县| 钟祥市| 融水| 基隆市| 伊金霍洛旗| 绍兴市| 九龙县| 大足县| 商洛市| 东安县| 安丘市| 郎溪县| 寿阳县| 康乐县| 东莞市| 温州市| 乌什县| 芮城县| 大英县| 涞水县| 扶绥县| 临湘市| 涿州市| 兴业县| 板桥市| 永城市| 永嘉县| 静宁县| 冷水江市| 鄂温| 松江区| 五大连池市| 洪雅县| 古交市| 永宁县|