我正在使用boost::split(lines, str, boost::is_any_of(delims));
现在我想知道针对每个拆分找到了哪个delim字符。我会把那个角色放在分裂线的末尾。这样我就可以重新创建原始字符串。我已经搜索过但在boost::split
中没有找到任何此类功能我是否需要使用其他任何功能?
答案 0 :(得分:1)
mb boost::tokenizer
与boost::char_separator
?
http://www.boost.org/doc/libs/1_51_0/libs/tokenizer/char_separator.htm
实施例
#include <iostream>
#include <string>
#include <boost/tokenizer.hpp>
int main()
{
std::string str = "hello, and what do. you? want";
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("", " ,.?");
tokenizer tokens(str, sep);
for (tokenizer::iterator pos = tokens.begin(); pos != tokens.end(); ++pos)
{
std::cout << *pos << std::endl;
}
}
http://liveworkspace.org/code/8dca20ecaa017000dd67096fc5d20aeb