如何访问结果集上的捕获组名称

时间:2019-02-05 10:23:00

标签: regex boost capture-group

下面的代码使用捕获组名称“ char”来解析简单的Input。使用调用 match [“ char”] 返回正确的匹配项。下面的循环也返回所有匹配,但是我找不到从迭代器结果返回到相应捕获组Name的方法。这怎么可能?

boost::xpressive::wsregex reg(boost::xpressive::wsregex::compile(L"(?P<char>.)"));
std::wstring test = L"a";

boost::xpressive::wsmatch pieces_match;
boost::xpressive::regex_search(test, pieces_match, reg);

// access direct with capture group works
std::wstring gh= pieces_match[L"char"];

for (auto i=pieces_match.begin();i!= pieces_match.end();i++)
{
  std::wstring text=i->str();
  // how to get from "i" the capture group name ???
}

0 个答案:

没有答案