posts - 58,  comments - 66,  trackbacks - 0
头文件 regex.hpp

常用的类
boost::regex 正则表达式

boost::cmatch 以char数组为容器,存储匹配返回值。
boost::smatch 以std::string为容器,存储匹配返回值。

boost::regex_match 匹配算法
boost::regex_search 查找算法
boost::regex_replace 替换算法

简单例子

#include <iostream>

#include <boost/regex.hpp>

int main( int argc, char* argv[] )
{
    char *buf = "This is boost::regex example";

    boost::regex exampleregex( "boost::regex" );
    boost::cmatch result;

    if( boost::regex_search( buf, result, exampleregex ) )
    {
        std::cout << result.str() << std::endl;
    }

    return 0;
}

注意regex.hpp的包含。要在开发工具中设置boost头文件所在位子。


posted on 2007-12-28 14:01 walkspeed 阅读(3435) 评论(0)  编辑 收藏 引用 所属分类: STL、Boost、范型编程C++语言

专题:Android  iPad jQuery Chrome OS

博客园首页  IT新闻  知识库  学英语  C++程序员招聘
标题  
姓名  
主页
验证码 *
内容(提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
[使用Ctrl+Enter键可以直接提交]
每天10分钟,轻松学英语
网站导航:



<2010年3月>
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿(4)

随笔分类(64)

随笔档案(58)

文章分类(3)

文章档案(3)

相册

收藏夹(9)

C++零碎

好友

搜索

  •  

积分与排名

  • 积分 - 65805
  • 排名 - 71

最新评论

阅读排行榜

评论排行榜