
On 2/7/06, David Abrahams <dave@boost-consulting.com> 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