Boost logo

Boost Users :

From: Lynn Allan (l_d_allan_at_[hidden])
Date: 2006-04-03 10:36:34


<alert comment="boost and regex newbie">

Thanks for providing and supporting boost::regex.

Maybe I'm the only one who finds the provided examples perhaps a bit
complicated to get "up to speed" ... much of the source code is parsing the
command line and then reading in a file and getting everything set up to do
rather advanced functionality (or at least it seems that way to this boost
newbie).

I'd appreciate examples that are more "baby steps with training wheels"
showing how to do the equivalent of "Hello, world".

Something something like the following for regex_replace?

void how_to_use_replace()
{
  string contents("String has &copy; twice &copy; to be replaced.");
  boost::regex reg("&copy;");
  contents = boost::regex_replace(contents, reg, "©");
  cout << contents << endl;
  // assert (contents == "String has © twice © to be replaced");
}

I realize there are simpler ways to accomplish this replacement (like
std::string.replace) and the above might not be "best practice", but these
kind of "barebones" examples might help "flatten" the learning curve for
this terrific library.

</alert>


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