Although boost::split indeed takes a predicate that operates on characters, there's a boost string algorithm that can split on substrings:
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <boost/algorithm/string/iter_find.hpp>
#include <boost/algorithm/string/finder.hpp>
int main()
{
std::string input = "message1foomessage2foomessage3";
std::vector<std::string> v;
iter_split(v, input, boost::algorithm::first_finder("foo"));
copy(v.begin(), v.end(), std::ostream_iterator<std::string>(std::cout, " "));
std::cout << '
';
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…