vs 2005 使用 boost regex

第一步:

Boost 入门及其VS2005下编译boost库 boost.regex库安装指南

Boost下载和Boost安装
去哪下载Boost呢?英文http://www.boost.org ,中文http://boost.c-view.org,可以找到一个.zip或.tar.gz格式的压缩包。下载完毕后,解压到某个目录,比如boost_1_26_0,里面一般有这么几个子目录:boost、libs、more、people、status、tools,看看没问题就行了。
如果Boost更新时您懒得去下载整个压缩包,只希望更新发生变动的文件;或者您是一位跟我一样的Boost Fans,希望跟踪Boost的最新变化,不妨使用CVS方式。首先得有一个CVS客户端软件,比如CvsGui或http://sourceforge.net/projects/cvsgui/提供的WinCVS、gCVS和MacCVS,分别适用于Windows、Linux和MacOS平台。下载、安装、启动三步曲。
VS2005下编译boost库
1. 启动VS2005,在Tool菜单中选择“Visual Studio 2005 Command Prompt“。VS会启动命令提示符窗口,并自动设置好相应的环境变量。
2. 转到<boost>/libs/regex/build目录下(<boost>是你存放boost代码的路径),运行以下命令即可进行编译,这个过程可能会比较久:
nmake -f vc8.mak

3. 运行以下命令进行安装,boost会把上一步产生的lib文件等拷贝到你的VC目录下。
nmake -f vc8.mak install

4. 最后清除安装时产生的临时文件:
nmake -f vc8.mak clean

3. 和 4.没有成功,手动复制到C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include目录下

第二步:

链接遇到问题:fatal error LNK1104: 无法打开文件“libboost_regex-vc80-mt-1_57.lib”

编译出来的lib如图

起初我下载的是57版本的。于是我又下载了53版本的zip文件,解压以后将其中的头文件放入C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include目录下。

fatal error LNK1104: 无法打开文件“libboost_regex-vc80-mt-gd-1_46_1.lib”

带有lib前缀表示的是使用静态链接。

为了使你的程序动态链接到boost,需要在:

#include <boost/regex.hpp>

之前定义宏:

#define BOOST_REGEX_DYN_LINK 1

#define BOOST_REGEX_DYN_LINK 1
#include <boost/regex.h>

时间: 2024-08-28 18:11:17

vs 2005 使用 boost regex的相关文章

boost::string or boost::regex

有时候写代码时会遇到下面问题 如果有一个文本文件,其包括内容类似于C语言,当中有一行例如以下格式的语句: layout (local_size_x = a,local_size_y = b, local_size_z = c) in; 当中用蓝色标记出的部分(layout, local_size_x, local_size_y, local_size_z, in)为keyword,斜体字部分(a, b, c)为数据类型为unsigned int的数字,请编写一个函数,用于从文件里抽取出a, b,

boost::regex

常见用法: boost::regex express; regex_match(str,express);  bool smatch what; cmatch what; typedef match_results<const char*> cmatch;typedef match_results<std::string::const_iterator> smatch; regex_search(str,what,express);bool what[0]; what[1]; re

c++ 使用boost regex库 总结

用java的时候觉得挺折腾,回头来弄c++才知道什么叫折腾...汗... 首先参考我写的这篇文章:http://www.cnblogs.com/qrlozte/p/4100892.html 我从sourceforge把整个boost的zip下载下来以后,我主要是在编译 boost regex的时候出问题了:boost有很多library,regex只是其中一个,怎么编译regex? 当然,第一步是查看文档,找到boost-path/doc/html/index.html打开,翻了半天倒找rege

#墙裂推荐Boost regex# C,C++11,Boost三种regex库性能比较

在最近的一个项目中,发现之前的正则匹配模块对于长字符串匹配性能损失比较厉害,因此对长字符串下的各种正则匹配进行了略微研究并附有实例.本文参考了博客http://www.cnblogs.com/pmars/archive/2012/10/24/2736831.html(下文称文1),这篇文章也是对三种regex库进行了比较,但有些地方我还有一些自己的见解,特此罗列如下,感谢这篇文章的作者. 1.C regex库 由于项目中一直用的都是C regex库,所以首先对C regex进行了研究.对于C r

#include &lt;boost/regex.hpp&gt;

boost C++的正则表达式库boost.regex可以应用正则表达式于C++.正则表达式大大减轻了搜索特定模式字符串的负担,在很多语言中都是强大的功能. boost.regex库中两个最重要的类是boost::regex和boost::smatch,它们都在boost/regex.hpp文件中定义.前者用于定义一个正则表达式,而后者可以保存搜索结果. 小结:C++的正则表达式库早已有之,但始终没有哪个库纳入到标准化流程中.目前该库已经顺利的成立新一代C++标准库中的一员,结束了C++没有标准

使用Boost Regex 的regex_search进行遍历搜索

在regex_search函数中,会将找到的第一个匹配结果保存到一个smatch类中. 然而如果搜索字符串中有多个匹配结果,则需要自己实现了. 在smatch中,有两个成员,官方文档如下: iterator first: An iterator denoting the position of the start of the match. iterator second An iterator denoting the position of the end of the match. 所以,

Boost::regex练习实例

#include <algorithm> #include <vector> #include <string> #include <iostream> #include <cassert> #include <boost/regex.hpp> using namespace std; using namespace boost; //写一个程序,提取<p></p>之间的内容 int main() { // r

Boost::Regex代码示例

看一个别人给出的例子,当我们输入“select 字符串 from 字符串”的时候,会得到输出:如果不符合这个格式,就会输出error.注意:在命令行下输入的时候,按ctrl+Z.回车表示行输入结束. #include <cstdlib> #include <stdlib.h> #include <boost/regex.hpp> #include <string> #include <iostream> using namespace std;

boost regex expression

Boost.Regex provides three different functions to search for regular expressions 1. regex_match #include <boost/regex.hpp> #include <string> #include <iostream> int main() { std::string s = "Boost Libraries"; boost::regex expr(