|
Boost Users : |
Subject: Re: [Boost-users] [regex] validating expressions
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-05-20 08:32:41
> 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?
They're both accepted by Perl-5.10 and hence by Boost.Regex.
HTH, 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