字符串分割函数 以前在网上看到了,忘记是哪儿了
std::vector split(std::string str, std::string pattern)
{
std::string::size_type pos,size,i;
std::vector result;
str += pattern;
size = str.size();
for(i=0; i
{
pos = str.find( pattern, i);
if (pos < size)
{
std::string s =str.substr(i, pos-i);
result.push_back(s);
i = pos+pattern.size()-1;
}
}
return result;
}
阅读(1996) | 评论(0) | 转发(0) |