| #include <iostream>
#include <algorithm>    // std::find
#include <string>
#include <vector>
using namespace std;
vector<string>* split(const string& str, const string& splitter)
{
    auto *res= new vector<string>;
    unsigned long start_pos=0;
    unsigned long end_pos;
    while (start_pos!=str.size()){
        if (str.find(splitter,start_pos)!=-1){
            end_pos=str.find(splitter,start_pos);
            res->push_back(str.substr(start_pos,end_pos-start_pos));
            start_pos=end_pos+ splitter.size();
        }else{
            res->push_back(str.substr(start_pos,str.size()-start_pos));
            break;
        }
    }
    return res;
}
int main() {
    vector<string>*vec = split("[i%%love%%c++%%]%%", "%%");
    for (auto &v:*vec)
        std::cout << v<<std::endl;
    return 0;
}
 运行结果: [ilove
 c++
 ]
 |