Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-07-24 17:32:11


Seth Nielson wrote:
> No, that won't suit my needs. Did you read my message? I said I need
> MARK to be a substring, not a single character.
>

This is implemented in my proposed super_string class. Docs at:

http://www.crystalclearsoftware.com/libraries/super_string/index.html

code for download in the boost vault at:

http://tinyurl.com/dbcye

Using super_string it looks like:

super_string s("<mark>Am<mark>A<mark>Test");
super_string::string_vector out_vec;
s.split("<mark>", out_vec);
//iterate on out_vec and process.

super_string is just a wrapper around std::string and boost libraries that do
the heavy lifting. If you want to do it yourself, you can use string_algo
directly. The relevent code that makes this work is:

  namespace alg = boost::algorithm;
  string predicate("<mark>");
  string input("<mark>Am<mark>A<mark>Test");
  vector<string> result;
  alg::iter_split(result, input,
                   alg::first_finder(predicate, alg::is_equal()));
    //iter_split will return entire string if no matches found

You can look at the implementation of super_string for hints...

http://www.crystalclearsoftware.com/libraries/super_string/super__string_8hpp-source.html

HTH,

Jeff


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net