Boost logo

Boost :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2006-02-06 23:32:14


On 2/7/06, David Abrahams <dave_at_[hidden]> wrote:
>
> Is a malformed regex supposed to crash the library? See enclosed .cpp file

It seems to me that it doesnt crash the library
But throws an exception that's not caught

[snip - stack trace and example]

With this:

#include <boost/regex.hpp>
#include <iostream>
#include <string>

int main()
{
  try
  {
    std::string line;
    boost::regex pat("^Subject: (Re: )?(.*");
    boost::smatch matches;

    while (std::cin)
    {
      std::getline(std::cin, line);
      if (boost::regex_match(line, matches, pat))
        std::cout << matches[2];
    }
  }
  catch(std::exception&e)
  {
    std::cerr << e.what() << std::endl;
  }
}

gives me this output:
Unmatched ( or \(

>
> --
> Dave Abrahams
> Boost Consulting
> www.boost-consulting.com
>

best regards,

--
Felipe Magno de Almeida

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