int_vec calculate_text_breaks(const xstring& text) { int_vec breaks; auto it = text.begin(); bool last = false; for (int i = 0; it != text.end(); ++it, ++i) { if (*it == ' ') { if (last) breaks.push_back(i); last = false; } else last = true; } return breaks; }
std::deque<xstring> split(const xstring& s, const xstring& delimitersRE) { std::deque<xstring> rv; const xstring fixed = std::regex_replace(s, std::wregex(L"\r"), L""); std::wregex rePattern(delimitersRE); std::wsregex_token_iterator iter(fixed.begin(), fixed.end(), rePattern, -1); std::wsregex_token_iterator end; for (; iter != end; ++iter) { const xstring& item = *iter; if (!item.empty()) rv.push_back(item); } return rv; }