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;
}
#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;
}
相关文章推荐
- boost正则表达式匹配一次
- 正则表达式,只匹配一次下化线!
- 【转载】:Boost正则表达式汉字匹配 收藏
- boost正则表达式多次匹配
- boost正则表达式多次匹配
- 【转载】:Boost正则表达式汉字匹配
- boost中关于正则表达式在vs2008不能匹配中文的问题
- boost正则表达式( 字母, 数字, 下划线,中文)
- 关于一个使用正则表达式匹配来写的显示时间的方法
- 正则表达式一匹配任何单一字符
- js中使用正则表达式,全局匹配时如何取到匹配串?
- Python-同时匹配邮箱和电话号码的正则表达式
- PowerShell中使用正则表达式匹配字符串实例
- Java - 正则表达式匹配模式
- JAVA正则表达式匹配,替换,查找,切割的总结
- 常用的匹配正则表达式和实例
- boost正则表达式小结
- 匹配http url 正则表达式
- PHP 正则表达式 匹配中文
- 模拟正则表达式匹配