Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-10-20 05:50:30


It's a little more complex in C++, how about:

std::string lookup_and_replace(const std::string& text)
{
static const boost::regex e("###var=([^#]*)###");
boost::smatch what; // stores what matched if anything
if(boost::regex_search(text, what, e))
{
  std::string result(what[-1]); // initialise with $`
  result.append(Session.getValue(what[1])); // append new text
  result.append(what[-2]); // append $'
  return result
}
else return text;
}

BTW I'm just typing this in, I haven't tried to compile / run it - I
haven't got time to debug your code for you :-)

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk