Dipro Sen
Dipro Sen

Reputation: 4670

boost::split return sep character

I am using boost::split(lines, str, boost::is_any_of(delims)); Now I want to know which delim character was found against each split. and I'll put that character at the end of the splitted lines. so that I can recreate the original string. I've searched but haven't found any such feature in boost::split Do I need to use any other function ?

Upvotes: 0

Views: 196

Answers (1)

ForEveR
ForEveR

Reputation: 55897

mb boost::tokenizer with boost::char_separator?

http://www.boost.org/doc/libs/1_51_0/libs/tokenizer/char_separator.htm

Example.

#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

Upvotes: 1

Related Questions