Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2006-04-24 12:37:27


>> If my code contains the following regexp,
>>
>> const boost::tregex
>> non_printables(__T("[^\0x21-\0x7E]+"));
>>
>>
>>
> Don't forget that your pattern is scanned first by the C++ compiler.
> In this case, this means that \0x21 is never seen by the RegExp
> engine; instead, it sees a NUL character (ASCII 0) followed by "x21".
> NUL is not valid in any pattern and thus an exception is thrown. Use
> double backslashes to get a backslash through to the engine.

Quite right, and just to add to that: it's very helpful if you add a
try...catch handler in main so that unhandled exceptions don't crash the
application. Or to put it another way, error handling is a "good thing" :-)

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