Ticket #4608 (closed Bugs: fixed)

Opened 7 years ago

Last modified 7 years ago

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

Reported by: <…> Owned by: johnmaddock
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.


Change History

comment:1 Changed 7 years ago by <…>

Compiler:Visual C++ 2008

comment:2 Changed 7 years ago by johnmaddock

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 johnmaddock

  • Status changed from new to closed
  • Resolution set to fixed

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


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

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

Note: See TracTickets for help on using tickets.