Opened 5 years ago

Last modified 5 years ago

#13206 new Bugs

regex constructor throws regex_error for simple expression

Reported by: Asbjørn Pedersen <ahp@…> Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.65.0 Severity: Problem
Keywords: regex error_range Cc:

Description

The code below throws boost::regex_error when creating an instance of boost::regex. I compile with visual studio 2015 and uses boost 1.65 precompiled for 32 bit windows (boost_1_65_1-msvc-14.0-32.exe)

#include "stdafx.h" #include <boost/regex.hpp> int main() {

try {

boost::regex re("[A-Z-.]+");

} catch (...) { assert(false); }

return 0;

}

Change History (1)

comment:1 by robic@…, 5 years ago

Error: Regex Construction .. 

Invalid range end in character class

'[A-Z-<<<HERE>>>.]+' 

In Perl, this compiles fine.
The dash here A-Z-. is ambiguous, it should be seen as a literal,
not a range operator.

Not all engines track this, but it is simple to do.

Note: See TracTickets for help on using tickets.