頭文件 regex.hpp
常用的類
boost::regex 正則表達(dá)式
boost::cmatch 以char數(shù)組為容器,存儲匹配返回值。
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的包含。要在開發(fā)工具中設(shè)置boost頭文件所在位子。
posted on 2007-12-28 14:01
walkspeed 閱讀(9527)
評論(0) 編輯 收藏 引用 所屬分類:
STL、Boost、范型編程 、
C++語言