how to regex parentheses
jiapengwen opened this issue · comments
文佳鹏 commented
show you my code; re2 version = 2023-07-01 release
RE2 re(R"(\(foo\))");
std::string word1;
std::string word2;
std::string word3;
bool ret = RE2::PartialMatch("(foo)", re, &word1, &word2, &word3);
std::cout << ret << std::endl;
std::cout << word1 << std::endl;
std::cout << word2 << std::endl;
std::cout << word3 << std::endl;
result
0
Paul Wankadia commented
re
contains zero capturing groups whereas the RE2::PartialMatch()
call expects three capturing groups, so the call fails; RE2::PartialMatch("(foo)", re);
would succeed.