On 3/15/02 5:11 PM, "soleani" wrote:
So, it seems that the call to:
static const boost::regex expression1( "\\" );
makes it core dump.
Not sure why you got a core dump, but I do know what the problem is. The
regular expression code is throwing an exception because your expression is
bad. Try this program:
#include <iostream>
#include
int main()
{
try {
boost::regex expression("\\");
} catch (const boost::bad_pattern& p) {
std::cout << "bad pattern: " << p.what() << '\n';
}
}
When you run it, you'll see that the expression causes a "bad_pattern"
exception because it has a backslash at the end. The problem is that you
have to escape the backslash once because of how C literals are interpreted
and again because of how characters in regular expressions are interpreted.
One fix is to use "\\\\" instead of "\\" so the backslash is escaped for the
regular expression:
boost::regex expression("\\\\");
Another is to use the "literal" flag when creating the regular expression so
the backslash doesn't need to be escaped:
boost::regex expression("\\", boost::regbase::literal);
Hope that helps.
-- Darin