Boost的regex和DEELX的正则表达式库,不是说都支持perl语言的正则语法么,咋么差距有点大?
润城 2013-07-31 05:16:09 //使用boost的regex,#include"boost/regex.hpp"
boost::regex reg("([a-zA-Z]+:\\/{0,2}){0,1}((\\w+(\\.{0,1}))*)*(\\/{0,1}.+)", boost::regex::icase | boost::regex::perl);
std::string s = "www.baidu.com/index.html";
string s2 = boost::regex_replace(s,reg,"$2");
std::cout<<"2:"<< s2<<endl; //输出结果为空:
//使用Deelx的正则表达式库#include "deelx.h"
static CRegexpT <char> regexp("([a-zA-Z]+:\\/{0,2}){0,1}((\\w+(\\.{0,1}))*)*(\\/{0,1}.+)");
char* ps1 = "www.baidu.com/index.html";
char* ps2 = regexp.Replace(ps1,"$2");
cout<<"ps2:"<<ps2<<endl; //输出结果为:www.baidu.com
//差距怎么这么大呢???不都说兼容perl的正则表达式语法么?