我想这是一件很愚蠢的事情,但是这不匹配,我也不知道为什么。我成功地编译了所有的东西,但都不匹配。我已经使用过RE(".*"),但它也不起作用。系统为OS (使用brew安装pcre )。
std::string s;
if (pcrecpp::RE("h.*o").FullMatch("hello", &s))
{
std::cout << "Successful match " << s << std::endl;
}发布于 2016-02-08 14:04:27
您正在尝试提取一个子模式(in &s),但没有包含任何括号来捕获该子模式。试试这个(未经测试,注意括号)。
std::string s;
if (pcrecpp::RE("(h.*o)").FullMatch("hello", &s))
{
std::cout << "Successful match " << s << std::endl;
}http://www.pcre.org/original/doc/html/pcrecpp.html的文档有一个类似的例子,说明:
失败是因为没有足够的子模式: !pcrecpp::RE("\w+:\d+").FullMatch("ruby:1234",&S;
https://stackoverflow.com/questions/35271434
复制相似问题