一:编译
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;
}

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;
}
shootingstars 2007-07-30 17:30 发表评论