Modify

Ticket #4608 (closed Bugs: fixed)

Opened 4 years ago

Last modified 4 years ago

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

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

Attachments

Change History

comment:1 Changed 4 years ago by gyk.net <gyk.net@…>

Compiler:Visual C++ 2008

comment:2 Changed 4 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 4 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.

View

Add a comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.