c ++ boost regex如何列出所有匹配的元素?

时间:2017-06-23 07:42:16

标签: c++ regex boost

我有一个问题,例如我有一个输入字符串" [1] [2] [3]"并且应该有输出" [1]" " [2]" " [3]" ,我试过但它不能正常工作,我的代码就像:

//My code 
const std::string strTypeName = "[1][2][3]";
std::vector<std::string> result;
boost::smatch mat;

boost::regex reg("(\\[[0-9]*\\])");
if (boost::regex_match(strTypeName, mat, reg, boost::format_all))
{
    for (boost::smatch::size_type index = 0; index < mat.size(); ++index)
    {
        result.push_back(mat[index]);
    }
}

who can tell me what is the matter with it, It will be great of help !

0 个答案:

没有答案