Hi, I have string line("a_1 = b_1 ( c_2 )") tokenizer< > tok(line); for (tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg) { cout << *beg << endl; } gives me a 1 b 1 c 2 I want to be able to specify delimiters like in strtok so that I get a_1, b_1 and c_2 but couldn't figure out how to specify the tokenizer function. Any suggestions? Regards Rajesh
On 1/15/02 2:47 PM, "rradh" <rradh@yahoo.com> wrote:
I want to be able to specify delimiters like in strtok so that I get a_1, b_1 and c_2 but couldn't figure out how to specify the tokenizer function. Any suggestions?
Here's an example: boost::char_delimiters_separator<char> separator(false, "", " "); boost::tokenizer<> tok(line, separator); Let me know if that helps. Perhaps we should ask John Bandela to include at least one example like this to make things clearer. -- Darin
On Tue, 15 Jan 2002, Darin Adler wrote: darin> On 1/15/02 2:47 PM, "rradh" <rradh@yahoo.com> wrote: darin> darin> > I want to be able to specify delimiters like in strtok so that I get darin> > a_1, b_1 and c_2 but couldn't figure out how to specify the tokenizer darin> > function. Any suggestions? darin> darin> Here's an example: darin> darin> boost::char_delimiters_separator<char> separator(false, "", " "); darin> boost::tokenizer<> tok(line, separator); darin> darin> Let me know if that helps. Perhaps we should ask John Bandela to include at darin> least one example like this to make things clearer. darin> I think part of the problem is the interface to char_delimiters_separater. Perhaps we could drop the first bool argument to simplify things a bit. Cheers, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
Hi, Thanks for your suggestion. The following works: char_delimiters_separator<char> separator(false,"(),= "); but as jeremy suggested, the first arg seems unnecessary. Regards Rajesh --- In Boost-Users@y..., Darin Adler <darin@b...> wrote:
On 1/15/02 2:47 PM, "rradh" <rradh@y...> wrote:
I want to be able to specify delimiters like in strtok so that I get a_1, b_1 and c_2 but couldn't figure out how to specify the tokenizer function. Any suggestions?
Here's an example:
boost::char_delimiters_separator<char> separator(false, "", " "); boost::tokenizer<> tok(line, separator);
Let me know if that helps. Perhaps we should ask John Bandela to include at least one example like this to make things clearer.
-- Darin
participants (3)
-
Darin Adler
-
Jeremy Siek
-
rradh