Boost logo

Boost Users :

Subject: [Boost-users] [regex] validating expressions
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2010-05-20 08:02:09


Is this the correct way to validate a regex expression?

bool validateExpression(std::string e)
{
   using namespace boost;
   return !expression.empty()
       && !regex(e, regex_constants::no_except).empty();
}

This passes all of my existing unit tests except for the following
strings which boost::regex reports as valid.

        "[[[A-Z]]"
        "[A-Z]??"

Both Qt's QRegExp and http://www.regexplanet.com/simple/index.html
report the first is invalid. Qt's QRegExp reports the second as invalid,
while http://www.regexplanet.com/simple/index.html report it as valid.

Is boost::regex right or remiss? Is there a better on line regex validator?

Thanks, Jeff


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