我正在使用boost::split(lines, str, boost::is_any_of(delims));
现在我想知道在每个拆分中找到了哪个 delim 字符。我会把那个字符放在分割线的末尾。这样我就可以重新创建原始字符串。我已经搜索但在boost::split
我需要使用任何其他功能吗?
问问题
184 次
1 回答
1
mbboost::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
于 2012-08-31T06:16:30.250 回答