I'm trying to use the split()
function provided in boost/algorithm/string.hpp
in the following function :
vector<std::string> splitString(string input, string pivot) { //Pivot: e.g., "##"
vector<string> splitInput; //Vector where the string is split and stored
split(splitInput,input,is_any_of(pivot),token_compress_on); //Split the string
return splitInput;
}
The following call :
string hello = "Hieafds##addgaeg##adf#h";
vector<string> split = splitString(hello,"##"); //Split the string based on occurrences of "##"
splits the string into "Hieafds" "addgaeg" "adf"
& "h"
. However I don't want the string to be split by a single #
. I think that the problem is with is_any_of()
.
How should the function be modified so that the string is split only by occurrences of "##"
?