Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2006-04-04 05:17:14


>> I'm trying to use boost-regex in my project that doesn't support
>> exceptions. Thus, when constructing a regular expression with
>> boost::regex expression(expr); and passig an invalid regular
>> expression, my program crashes.
>>
>> What can I do to make sure my regular expression is valid before
>> passing it to exception-throwing methods like that one?
>>

There is a no_except flag that can be passed the regex constructor/assign
methods to disable throwing of exceptions:

boost::regex e("bad**string", boost::regex_constants::perl |
boost::regex_constants::no_except);

if(e.empty())
{
    std::cout << "oops" << std::endl;
}

However, I notice that I removed all mention of this from the docs when I
updated the interface to match the TR1 spec. It's non-the-less still
supported however.

John.


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