VC利用boost库解析正则表达式
cmd
vcvars32.bat
cd d:oost_1_32_0libs egexuild
d:
nmake -fvc6.mak
nmake -fvc6.mak install (文章来源 www.iocblog.net)
注意,别看下载下来的数据包没有多大,解压缩之后达到了100多m,编译完之后为109m,占用131m,所以安装时一定注意空出足够的空间,敲入nmake -fvc6.mak后等待的时间比较长,屏幕上还会出现一大堆英语,可以不做考虑.按照步骤往下敲就行了.压缩包内文档很详细,参照文档继续就可以了.
在vc6中集成:tools->options->directories->include files
加入:d:oost_1_32_0
编写一个源程序测试一下:
| #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; } |
输入: select name from table
输出: str:select name from table
str:name
str:table
Tag: boost库 ,正则表达式
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。