Opened 12 years ago

Closed 12 years ago

#4608 closed Bugs (fixed)

boost::regex accepts invalid regular expressions like "\\d++"

Reported by: gyk.net <gyk.net@…> Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.44.0 Severity: Problem
Keywords: regex Cc:

Description

In programming languages that don't support possessive quantifier,eg. Python and C#,"\d++" is considered as an illegal nested quantifier.And in boost::xpressive,"
d++" will raise a runtime exception.However,it's valid in boost::regex.

wchar_t* s = L"abc123" ;
wregex e(L"\\d+++", boost::regex::normal) ;
wcmatch m ;

if(regex_search(s, m, e)){
    wcout <<  m[0] << endl ;
}

The output is 123.

Change History (3)

comment:1 by gyk.net <gyk.net@…>, 12 years ago

Compiler:Visual C++ 2008

comment:2 by John Maddock, 12 years ago

Boost.Regex is intended to to track the regular expressions supported by Perl-5.x, and pocessive quantifiers were introduced in Perl-5.10 which is why we support them.

However, you are correct that three +'s sould raise an error - I'll fix that shortly.

comment:3 by John Maddock, 12 years ago

Resolution: fixed
Status: newclosed

(In [65145]) In Perl mode then "something+++" should be an error. Add the necessary error handling. Fixes #4608.

Note: See TracTickets for help on using tickets.