这里是根据分号来进行拆分,上源码展示:
std::string str = "255,245,255;125,123,134;125,67,46;57,34,50";
std::vector<std::vector<int>> colors;
colors.clear();
int currentPosition = 1;
while(currentPosition > 0)
{
currentPosition = static_cast<int>(str.find_first_of(";"));
std::string tempStr = str.substr(0,currentPosition);
str = str.substr(currentPosition+1);
cout <<tempStr<<endl;
}
最后拆分结果如下: