惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Last Week in AI
Last Week in AI
D
DataBreaches.Net
腾讯CDC
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
罗磊的独立博客
月光博客
月光博客
MyScale Blog
MyScale Blog
U
Unit 42
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
G
Google Developers Blog
博客园 - 【当耐特】
D
Docker
I
InfoQ
雷峰网
雷峰网

博客园 - shootingstars

硬件相关概念 我的Function C的可变参数 C++概念网摘 Mifare 串行读取协议 韦根协议 学习C的可变参数 关于汇编程序调用各种C函数的例子 如何移植Java的类中的super到C++代码中 编译原理学习 关于标准库中的ptr_fun/binary_function/bind1st/bind2nd 使用python编写每日构建工具 boost::regex学习(5) - shootingstars - 博客园 boost::regex学习(4) - shootingstars - 博客园 boost::regex学习(3) boost::regex学习(2) 《世界大战》《变形金刚》观后感 boost::algorithm学习 五种迭代器
boost::regex学习(1)
shootingstars · 2007-07-30 · via 博客园 - shootingstars

一:编译
boost的正则表达式需要编译(如果不需要全部Boost的功能的话,请不要build all boost,那会花掉好几个小时。我推荐仅仅build需要的库就好。)
原有的boost 1.33似乎使用vc8编译的时候有问题。下载boost 1.34.1,使用“Visual Studio 2005 Command Prompt”,进入到boost_1_34_1\libs\regex\build:
nmake vc8.mak
OK,生成的文件在vc80下。

二:学习正则表达式
http://www.cppblog.com/Files/shootingstars/deelx_zh.rar
不错的正则表达式的学习资料,顺便推荐一下:
http://www.regexlab.com/
这个站长还与我有个一信之缘(我写的P2P之UDP穿透NAT的原理与实现(附源代码))。站长的这个正则库在CodeProject获得了不错的评价。

三:简单的例子
    std::string regstr = "a+";
    boost::regex expression(regstr);
    std::string testString = "aaa";

    // 匹配至少一个a
    if( boost::regex_match(testString, expression) )
    {
        std::cout<< "Match" << std::endl;
    }
    else
    {
        std::cout<< "Not Match" << std::endl;
    }