#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;
}

解决方案 »

  1.   

    是正确的,出现这个错误 fatal error C1083: 无法打开包括文件:“stdafx.h”: No such file or directory
      

  2.   

    这代码不是我写的,网上当的,关于boost 我刚开始搞,不明白肿么回事
      

  3.   

    既然提示:“stdafx.h”: No such file or directory,那就把这个#include "stdafx.h"去掉试试,或者找找你抄来的工程中,是否有这个文件
      

  4.   

    去了,一堆问题,正在搞正则表达式,刚刚开始搞,搞的我都想吐了,看来是我的环境配的有问题
    出现这个错误了fatal error LNK1104: 无法打开文件“libboost_regex-vc80-mt-gd-1_49.lib谁搞过这个正则表达式,给点帮助
      

  5.   

    “stdafx.h”是创建MFC工程自带的
    纯c++的用不到。
    自己创建不同的工程用不同的代码,光从网上抄有时会搞的4不象
      

  6.   

    这个我知道,这正则表达式谁搞过,给点帮助,出这个了,fatal error LNK1104: 无法打开文件“libboost_regex-vc80-mt-gd-1_49.lib