[C++] 拆分字符串_split_with_string →→→→→进入此内容的聊天室

来自 , 2020-06-11, 写在 C++, 查看 133 次.
URL http://www.code666.cn/view/9f699296
  1. vector<string> split_with_string(const string& str, const string& delim)
  2. {
  3.     vector<string> substr_vt;
  4.     int where_delim;
  5.     int old_offset = 0;
  6.     string temp;
  7.  
  8.     while((where_delim = str.find(delim, old_offset)) != string::npos) {
  9.         temp.assign(str, old_offset, where_delim - old_offset);
  10.         if (!(temp.empty())) {
  11.             substr_vt.push_back(temp);
  12.         }
  13.         old_offset = where_delim + delim.length();
  14.         where_delim = old_offset;
  15.     }
  16.     temp.assign(str, old_offset, str.length() - old_offset);
  17.     if (!(temp.empty())) {
  18.         substr_vt.push_back(temp);
  19.     }
  20.  
  21.     return substr_vt;
  22. }
  23.  

回复 "拆分字符串_split_with_string"

这儿你可以回复上面这条便签

captcha