如图为什么输出结果不是 ABC 12 4
我正则表达式没有写错,已测试过了。
code
int splitkey()
{
list cols;
string weekend = "ABC(012,04)";
regex pattern("(\w+)|([1-9]\d*)");
const std::sregex_token_iterator end; //需要注意一下这里
int no1=1;
for (std::sregex_token_iterator i(weekend.begin(),weekend.end(), pattern); i != end ; ++i)
{
cols.push_back(*i);
std::cout <<no1++<<":"<< *i << std::endl;
}
return 0;
}