split()
次の関数で提供され ている関数を使用しようとしてboost/algorithm/string.hpp
います:
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;
}
次の呼び出し:
string hello = "Hieafds##addgaeg##adf#h";
vector<string> split = splitString(hello,"##"); //Split the string based on occurrences of "##"
"Hieafds" "addgaeg" "adf"
文字列を&に分割します"h"
。ただし、文字列を1つに分割したくありません#
。問題はにあると思いますis_any_of()
。
文字列が?の出現によってのみ分割されるように、関数をどのように変更する必要があり"##"
ますか?