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的正则表达式语法么?
...全文
283 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
润城 2013-08-01
  • 打赏
  • 举报
回复
/转与不转都可以,我用Regex Match Tracer 测试了
taodm 2013-08-01
  • 打赏
  • 举报
回复
Regex Match Tracer 能代表boost?
taodm 2013-07-31
  • 打赏
  • 举报
回复
/需要转义么?
赵4老师 2013-07-31
  • 打赏
  • 举报
回复
这个世界上最大的差别和最远的距离都存在于“说”和“做”之间。

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧