cocos2d-x 对传入的字符串进行解析分割 解析

来源:互联网 发布:tensorflow 图片分类 编辑:程序博客网 时间:2024/06/11 02:41

//对传入的字符串进行解析分割
vector<std::string> schoolBusLayer::httpGetDateSplit(std::string str,std::string separator )
{
 vector<string> result; 
 string::size_type cutAt =0; 
 int times = 1;
 int lastAt = 0;
 while( (cutAt = str.find_first_of(separator,times))!=str.npos ) 
 { 
  if(cutAt > 0) 
  {
   result.push_back(str.substr(0, cutAt)); 
  }
  str = str.substr(cutAt + 3); 
 }    
 if(str.length() > 0) 
 { 
  result.push_back(str); 
 } 
 return result; 
}

 

 

用法:std::vector<string> vec_str_num;   vec_str_num= httpGetDateSplit(bufferSchool,"101");

原创粉丝点击