您的位置:首页 > 其它

boost正则表达式匹配一次

2009-07-05 15:12 316 查看
#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[])

{

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;

}

system( "pause" );

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: