Boost logo

Boost Users :

From: David Brownell (david_brownell_at_[hidden])
Date: 2005-01-27 18:38:04

I am attempting to split a string with the string_algo library, using the
code below. It appears that the split algorithm is designed to split on
instances of individual characters rather than sequences of characters. Is
there something I can do to split on a substring? The code below
illustrates the problem, where I am forces to use the is_any_of predicate
rather than something that implies equality. It seems like this is a
trivial use of the algorithm, so there could easily be something that I am

    typedef std::vector<boost::iterator_range<char const *> >

    ResultsType results;
    static char const STRING[] = "this\r\nis\r\n\r\na test!";

                 boost::iterator_range<char const *>(STRING, STRING +
                 boost::is_any_of("\r\n")); // The problem is here. I
would like to be able
                                             // to use something like
equals, but split requires
                                             // a predicate that takes a
single argument rather than
                                             // a range.

    for(ResultsType::const_iterator rptr = results.begin();
        rptr != results.end();
            std::cout << "'" << std::string(rptr->begin(), rptr->end()) <<

David Brownell

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at