Opened 7 years ago

Closed 7 years ago

#4608 closed Bugs (fixed)

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

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


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.

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by <…>

Compiler:Visual C++ 2008

comment:2 Changed 7 years ago by John Maddock

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 Changed 7 years ago by John Maddock

Resolution: fixed
Status: newclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain John Maddock.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.