我正在尝试使用正则表达式在C++中编写split函数。目前我已经想出了以下代码:
vector<string> split(string s, regex r)
{
vector<string> splits;
while (regex_search(s, r))
{
int split_on = // index of regex match
splits.push_back(s.substr(0, split_on));
s = s.substr(split_on + 1);
}
splits.push_back(s);
return splits;
}
我想知道如何填写注释行。