Я пытался разбить строку на двойные символы новой строки("\n\n"
).
input_string = "firstline\nsecondline\n\nthirdline\nfourthline";
size_t current;
size_t next = std::string::npos;
do {
current = next + 1;
next = input_string.find_first_of("\n\n", current);
cout << "[" << input_string.substr(current, next - current) << "]" << endl;
} while (next != std::string::npos);
дает мне вывод
[firstline]
[secondline]
[]
[thirdline]
[fourthline]
что явно не то, что я хотел. Мне нужно получить что-то вроде
[first line
second line]
[third line
fourthline]
Я также пробовал boost::split
, но это дает тот же результат. Что мне не хватает?