Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-08-22 13:56:01


izua wrote:
> Hmm..
> I've checked out the documentation, and the examples are really,
> really way out of my league. Is there a wrapper function or something
> like this around it? Or anyone has one handy?
> I'll really appreciate it.

See if you can understand this one then:

void find_all(const std::string& s, const boost::regex& e)
{
  boost::sregex_iterator i(s.begin(), s.end(), e), j;
  while(i != j)
  {
    for(unsigned s = 0; s <= i->size(); ++s)
    {
      std::cout << "Location of sub-expression "
        << s << " match is " << i->position(s) << std::endl;
      std::cout << "Length of sub-expression "
        << s << " match is " << i->length(s) << std::endl;
      std::cout << "Text of sub-expression "
        << s << " match is \"" << i->str(s) << "\"" << std::endl;
    }
    ++i;
  }
}

John.


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