Boost logo

Boost Users :

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


John Maddock wrote:
>> 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.

Thanks again John,

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